As suggested by redsummernight in the PR for AO3-2452 (in this comment), it would be good to add a unique index on (meta_tag_id, sub_tag_id) to the meta_taggings table. There’s already a constraint in ruby to try to prevent duplicate MetaTaggings, but it would be better to enforce that constraint in the database, as well.
From james:
ao3app@test-app10:~/app/current$ bundle exec rake db:migrate
== 20190611212339 AddUniqueIndexToMetaTaggings: migrating =====================
-- add_index(:meta_taggings, [:meta_tag_id, :sub_tag_id], {:unique=>true})
-> 4.9407s
-- remove_index(:meta_taggings, [:meta_tag_id])
-> 0.6319s
== 20190611212339 AddUniqueIndexToMetaTaggings: migrated (5.5730s) ============
So we can call this ready to go.