From 41c5efe8794c8765b4b0af3d3f35bcb252fda3c7 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 20 May 2026 05:02:48 +0200 Subject: [PATCH] Added global match column to actors. --- migrations/20260520044355_actors_unique.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/migrations/20260520044355_actors_unique.js b/migrations/20260520044355_actors_unique.js index 2254edd3..4546f5ac 100644 --- a/migrations/20260520044355_actors_unique.js +++ b/migrations/20260520044355_actors_unique.js @@ -3,11 +3,30 @@ exports.up = async function(knex) { DROP INDEX unique_actor_slugs; CREATE UNIQUE INDEX unique_actor_slugs ON actors (slug, entry_id) WHERE entity_id IS NULL; `); + + await knex.schema.alterTable('actors', (table) => { + table.boolean('allow_global_match'); + }); }; exports.down = async function(knex) { + const dupes = await knex('actors') + .select('name', 'slug', knex.raw('count(*) as count')) + .whereNull('entity_id') + .groupBy('name', 'slug') + .havingRaw('count(*) > 1') + .orderBy('count', 'desc'); + + if (dupes.length > 0) { + console.log('DUPES\n', dupes.map((actor) => `${actor.name} ${actor.slug} ${actor.count}`).join('\n')); + } + await knex.raw(` DROP INDEX unique_actor_slugs; CREATE UNIQUE INDEX unique_actor_slugs ON actors (slug) WHERE entity_id IS NULL; `); + + await knex.schema.alterTable('actors', (table) => { + table.dropColumn('allow_global_match'); + }); };