-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Bulk adding tags created "duplicate" posts_tags rows from editor po…
…sts page #21414 The commit includes a migration which adds a unique index to posts_tags table and handles the related error when bulk adding posts. The errors are ignored because the tags user wants to add are added/exist. This respects the editor's expectation as posts have the tags as the end result.
- Loading branch information
Showing
3 changed files
with
11 additions
and
2 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...er/data/migrations/versions/5.100/2024-12-01-18-54-00-add-unique-tag-post-relationship.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const {createIrreversibleMigration} = require('../../utils'); | ||
const {addUnique} = require('../../../schema/commands'); | ||
const logging = require('@tryghost/logging'); | ||
|
||
module.exports = createIrreversibleMigration(async (knex) => { | ||
logging.info('Adding unique constraint to tag-post relationship'); | ||
|
||
await addUnique('posts_tags', ['tag_id', 'post_id'], knex); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters