Added tag reassociation and dedupe migration.

This commit is contained in:
DebaucheryLibrarian
2026-02-22 06:24:26 +01:00
parent e3b922da6c
commit b95e2fadf7
6 changed files with 156 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
exports.up = async (knex) => {
// dedupe
await knex.raw(`
DELETE
FROM releases_tags
WHERE ctid IN
(
SELECT ctid
FROM(
SELECT
*,
ctid,
row_number() OVER (PARTITION BY release_id, original_tag ORDER BY ctid)
FROM releases_tags
)s
WHERE row_number >= 2
)
`);
await knex.schema.alterTable('releases_tags', (table) => {
table.increments('id');
table.unique(['release_id', 'original_tag']);
});
};
exports.down = async (knex) => {
await knex.schema.alterTable('releases_tags', (table) => {
table.dropColumn('id');
table.dropUnique(['release_id', 'original_tag']);
});
};