When running consistency_fail to check for uniqueness constraints enforced in the codebase but not backed by the database, one of the results shows a missing index for CommonTaggings:
There is, however, a very similar uniqueness constraint that is enforced by the database:
The difference is the filterable_type column, which is used to allow CommonTagging#filterable to be polymorphic. However, in practice, CommonTagging#filterable is always a Tag, so the filterable_type column serves no practical purpose. It would be nice to get rid of the column entirely, to reflect the fact that the CommonTagging class is used to define relationships between tags.
Any PR for this issue should handle these things:
A migration to drop the filterable_type column for common_taggings, and if necessary adjust the unique index.
Updating the CommonTagging class so that the filterable association has class_name: "Tag" instead of polymorphic: true.
Updating any associations that are through: :common_taggings, since switching away from polymorphic means that source_type: 'Tag' is no longer needed.
Modifying all other classes so that there are no more references to common_taggings.filterable_type.
Testing Instructions: Any user can check the following:
View a tag with a lot of parents and children, and make sure they display correctly.
View the "All Fandoms" page, both logged-in and logged-out.
View the fandom list for each medium (including Uncategorized Fandoms).
View a large collection and try filtering the fandoms by medium.
In addition, tag wranglers can check the following:
Log in as a tag wrangler.
View the list of unassigned fandoms and try filtering by medium.
View the tag wranglers page and try to filter by medium.
Edit a tag to add a new parent, and make sure the new parent appears when viewing the tag.
Edit a tag to remove an existing parent, and make sure the parent is gone when viewing the tag.
Edit a tag to add a new child, and make sure the new child appears when viewing the tag.
Edit a tag to remove an existing child, and make sure the child is gone when viewing the tag.