New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MBS-8838: Add gids to all *_type* tables #259
Conversation
@@ -21,6 +21,7 @@ CREATE TABLE application | |||
|
|||
CREATE TABLE area_type ( -- replicate | |||
id SERIAL, -- PK | |||
gid uuid NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this would practically cause us any problems, but since ALTER TABLE
in the upgrade script will add the column to the end, I wonder if we should do the same here for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, actually, I guess it'd break data dump imports if we didn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, unfortunately Postgres (even in 9.5) still doesn’t allow freely ordering columns. :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, unfortunate. I pushed an update.
Some missing pieces I see. :) Could do with some unique indexes in admin/sql/CreateIndexes.sql and admin/sql/caa/CreateIndexes.sql like
upgrade.json in the root of the repository should be updated with a key for schema version "23" (then you just need to add "20160516-mbs-8838.sql" to slave and standalone sub-keys, meaning it'll run on both types of servers when someone runs upgrade.sh). |
After adding indexes, run |
OK, indexes added and upgrade.json is updated. Is WS update the only thing left there, assuming I got the rest right? |
Yeah, I think so. 💯 So now you've got the annoying part for last. |
But I don't see any change to upgrade.json here. :P |
Forgot to push. 😱 |
cc99323
to
7beda3e
Compare
I updated
|
Looks good so far. For the tables you mentioned:
|
nsort_by { $fallback_type_order{$_} } | ||
grep { exists $fallback_type_order{$_} } | ||
map { $_->name } | ||
$release_group->all_secondary_types; | ||
my ($fallback_gid) = | ||
nsort_by { $fallback_type_order{$_} } | ||
grep { exists $fallback_type_order{$_} } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%fallback_type_order
doesn't have gids for keys, so nothing will exist there. You can try removing the map { $_->name }
above, use $_->name
as the key into %fallback_type_order
, and then do $fallback->name
and $fallback->gid
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So something like this?
my $fallback =
nsort_by { $fallback_type_order{$_} }
grep { exists $fallback_type_order{$_} }
$release_group->all_secondary_types;
if ($fallback) {
$attr{type} = $fallback->name;
$attr{"type-id"} = $fallback->gid;
} else {
$attr{type} = $release_group->primary_type->name;
$attr{"type-id"} = $release_group->primary_type->gid;
}
Though I'm having trouble understanding when $fallback
is actually used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, except in nsort_by/grep you should do $fallback_type_order{$_->name}
since it's keyed by name.
The fallback stuff is used when the primary type is Album
. If there's a more specific secondary type, it'll output that instead of Album
. I'm guessing this is because we used to only have a flat list of release types, so you would just have "Compilation" instead of "Album (primary), Compilation (secondary)", so ouputting "Compilation" is more backwards-compatible.
That's only for the type
attribute. We still output the primary/secondary types separately below, which people should ideally be using instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed.
Tests should be passing now, but I still have some problems with |
INSERT INTO work_alias_type VALUES (1, 'Work name', NULL, 0, NULL, 'a18cab3f-0ae2-3978-8f75-dd9c09702b25'); | ||
INSERT INTO work_alias_type VALUES (2, 'Search hint', NULL, 0, NULL, '02238bc1-dfd8-39a8-bbf8-c697747291ec'); | ||
|
||
INSERT INTO work_type VALUES (29, 'Musical', NULL, 2, 'Musical theatre is a form of theatrical performance that combines songs, spoken dialogue, acting, and dance.', '9ca5e067-acf7-3cd6-baa4-92bf1975bf24'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep each group sorted so it's easy to see what was actually added? (F5 in sublime, but you prob. knew that.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore that, F5 doesn't sort numerically. Forgot I have a plugin to do that. So I'll just use it here.
We added a dep. on |
I added the necessary changes to the JSON web service and fixed the browse tests. Back to you. :) |
(1, 'Attribute', false), | ||
(2, 'Free attribute', true); | ||
(1, '325c079d-374e-4436-9448-da92dedef3ce', 'Attribute', false), | ||
(2, '425c079d-374e-4436-9448-da92dedef3ce', 'Free attribute', true); | ||
INSERT INTO work_attribute_type_allowed_value (id, work_attribute_type, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to add gid
there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
I'm currently a bit stuck with running tests. See http://chatlogs.metabrainz.org/brainzbot/metabrainz/2016-03-26/?msg=3549941&page=4. |
Fixed some more tests, still a bunch of failures left. But I think it would be easier for us if we merge this and let Jenkins run things (especially since you're having trouble running them on your machine). |
Sure. Is there anything else apart from tests that needs fixing? |
Not that I can think of right now. We might find out something when more tests start failing. :) |
Alright. :) |
http://tickets.musicbrainz.org/browse/MBS-8838