From 02c4398e48c95c23f61d13f9619e88a67caa88e5 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 30 Jul 2025 00:00:10 +0200 Subject: [PATCH] Fix handling of too long page image urls migration (#1552) * Delete duplicated chapter page rows by index and chapter In case duplicated rows based on the condition for the updated unique constraint existed, the new constraint could not be added and caused the migration to fail * Drop UC_PAGE only if it exists --- .../migration/M0050_FixHandlingOfTooLongPageImageUrls.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0050_FixHandlingOfTooLongPageImageUrls.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0050_FixHandlingOfTooLongPageImageUrls.kt index 1e191fd7..48f4f940 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0050_FixHandlingOfTooLongPageImageUrls.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0050_FixHandlingOfTooLongPageImageUrls.kt @@ -13,7 +13,14 @@ import de.neonew.exposed.migrations.helpers.SQLMigration class M0050_FixHandlingOfTooLongPageImageUrls : SQLMigration() { override val sql: String = """ - ALTER TABLE PAGE DROP CONSTRAINT UC_PAGE; + DELETE FROM PAGE + WHERE ID NOT IN ( + SELECT MIN(ID) + FROM PAGE + GROUP BY INDEX, CHAPTER + ); + + ALTER TABLE PAGE DROP CONSTRAINT IF EXISTS UC_PAGE; ALTER TABLE PAGE ADD CONSTRAINT UC_PAGE UNIQUE (INDEX, CHAPTER); ALTER TABLE PAGE ALTER COLUMN IMAGE_URL VARCHAR; -- the default length is `Integer.MAX_VALUE`