From 5e2909c531c1df9708ae62f5d499812c0027adc9 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Thu, 18 Feb 2021 04:44:04 +0100 Subject: [PATCH] Fixed actor unique index preventing multiple actors with the same slug on a different network. Changed scene delete query to be able to handle more scene IDs. --- migrations/20190325001339_releases.js | 2 +- src/releases.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/migrations/20190325001339_releases.js b/migrations/20190325001339_releases.js index ab5d53a9..951d0128 100644 --- a/migrations/20190325001339_releases.js +++ b/migrations/20190325001339_releases.js @@ -999,7 +999,7 @@ exports.up = knex => Promise.resolve() // allow vim fold return knex.raw(` CREATE UNIQUE INDEX unique_actor_slugs_network ON actors (slug, entity_id, entry_id); - CREATE UNIQUE INDEX unique_actor_slugs ON actors (slug, (entity_id IS NULL)); + CREATE UNIQUE INDEX unique_actor_slugs ON actors (slug) WHERE entity_id IS NULL; CREATE UNIQUE INDEX releases_search_unique ON releases_search (release_id); CREATE INDEX releases_search_index ON releases_search USING GIN (document); diff --git a/src/releases.js b/src/releases.js index c6aa3540..9ecb6759 100644 --- a/src/releases.js +++ b/src/releases.js @@ -146,12 +146,13 @@ async function deleteScenes(sceneIds) { return 0; } + // there can be too many scene IDs for where in, causing a stack depth error await knex('movies_scenes') - .whereIn('scene_id', sceneIds) + .whereRaw('scene_id = ANY(:sceneIds)', { sceneIds }) .delete(); const deleteCount = await knex('releases') - .whereIn('id', sceneIds) + .whereRaw('id = ANY(:sceneIds)', { sceneIds }) .delete(); logger.info(`Removed ${deleteCount}/${sceneIds.length} scenes`);