We're updating the issue view to help you get more done. 

Drop filterable_type column for common_taggings

Description

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:

1 CommonTagging common_taggings (common_tag_id, filterable_id)

There is, however, a very similar uniqueness constraint that is enforced by the database:

1 add_index "common_taggings", ["common_tag_id", "filterable_type", "filterable_id"], :name => "index_common_tags", :unique => true

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:

  1. A migration to drop the filterable_type column for common_taggings, and if necessary adjust the unique index.

  2. Updating the CommonTagging class so that the filterable association has class_name: "Tag" instead of polymorphic: true.

  3. Updating any associations that are through: :common_taggings, since switching away from polymorphic means that source_type: 'Tag' is no longer needed.

  4. Modifying all other classes so that there are no more references to common_taggings.filterable_type.

Testing Instructions: Any user can check the following:

  1. View a tag with a lot of parents and children, and make sure they display correctly.

  2. View the "All Fandoms" page, both logged-in and logged-out.

  3. View the fandom list for each medium (including Uncategorized Fandoms).

  4. View a large collection and try filtering the fandoms by medium.

In addition, tag wranglers can check the following:

  1. Log in as a tag wrangler.

  2. View the list of unassigned fandoms and try filtering by medium.

  3. View the tag wranglers page and try to filter by medium.

  4. Edit a tag to add a new parent, and make sure the new parent appears when viewing the tag.

  5. Edit a tag to remove an existing parent, and make sure the parent is gone when viewing the tag.

  6. Edit a tag to add a new child, and make sure the new child appears when viewing the tag.

  7. Edit a tag to remove an existing child, and make sure the child is gone when viewing the tag.

Environment

None

Status

Assignee

Unassigned

Reporter

ticking instant

Roadmap

Tags
Tag Wrangling

Priority

Medium

Affects versions

0.9.247

Fix versions

None

Components

None

Difficulty

Medium

Required Access Level

Tag Wrangler

Milestone

Internal 0.9