Skip to content
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

Merged
merged 20 commits into from Mar 29, 2016
Merged

Conversation

gentlecat
Copy link
Contributor

@@ -21,6 +21,7 @@ CREATE TABLE application

CREATE TABLE area_type ( -- replicate
id SERIAL, -- PK
gid uuid NOT NULL,
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor

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. :-/

Copy link
Contributor Author

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.

@mwiencek
Copy link
Member

Some missing pieces I see. :)

Could do with some unique indexes in admin/sql/CreateIndexes.sql and admin/sql/caa/CreateIndexes.sql like

CREATE UNIQUE INDEX link_type_idx_gid ON link_type (gid);

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).

@mwiencek
Copy link
Member

After adding indexes, run ./admin/GenerateSQLScripts.pl admin/sql/ to automatically update all the DropIndexes.sql files too.

@gentlecat
Copy link
Contributor Author

OK, indexes added and upgrade.json is updated.

Is WS update the only thing left there, assuming I got the rest right?

@mwiencek
Copy link
Member

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.

@mwiencek
Copy link
Member

But I don't see any change to upgrade.json here. :P

@gentlecat
Copy link
Contributor Author

Forgot to push. 😱

@gentlecat
Copy link
Contributor Author

@gentlecat gentlecat force-pushed the mbs-8838 branch 2 times, most recently from cc99323 to 7beda3e Compare March 21, 2016 06:08
@gentlecat
Copy link
Contributor Author

I updated XMLSerializer and most things seem to be working. However, I couldn't figure out how to integrate gid columns from the following tables:

  • cover_art_archive.art_type
  • editor_collection_type
  • series_ordering_type
  • work_attribute_type_allowed_value

@mwiencek
Copy link
Member

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{$_} }
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

@gentlecat
Copy link
Contributor Author

Tests should be passing now, but I still have some problems with WikiDoc ones. Check please?
https://gist.github.com/anonymous/fd7261a2a390b3408d30

@gentlecat gentlecat changed the title [WIP] MBS-8838: Add gids to all *_type* tables MBS-8838: Add gids to all *_type* tables Mar 25, 2016
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');
Copy link
Member

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.)

Copy link
Member

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.

@mwiencek
Copy link
Member

We added a dep. on Text::Diff3 recently, so it looks like your tests are failing because of that. cpanm Text::Diff3.

@mwiencek
Copy link
Member

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)
Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@gentlecat
Copy link
Contributor Author

I'm currently a bit stuck with running tests. See http://chatlogs.metabrainz.org/brainzbot/metabrainz/2016-03-26/?msg=3549941&page=4.

@mwiencek
Copy link
Member

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).

@gentlecat
Copy link
Contributor Author

Sure. Is there anything else apart from tests that needs fixing?

@mwiencek
Copy link
Member

Not that I can think of right now. We might find out something when more tests start failing. :)

@gentlecat
Copy link
Contributor Author

Alright. :)

@mwiencek mwiencek merged commit aaf788d into schema-change-2016-q2 Mar 29, 2016
@mwiencek mwiencek deleted the mbs-8838 branch March 29, 2016 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants