From 1b4f8018aede636a767ca3362c69cb884d998514 Mon Sep 17 00:00:00 2001 From: tiny Flutter team Date: Tue, 7 Apr 2026 22:39:08 +0700 Subject: [PATCH] chore: fix SQLite-specific syntax in PostgreSQL migrations --- .../V20200810165912__thumbnails_part_3.sql | 4 +-- ...20200820154318__metadata_fields_part_3.sql | 2 -- .../V20230922143307__server_settings.sql | 2 +- .../V20240614170012__user_kobo_role.sql | 4 +-- .../V20250108115503__user_roles.sql | 35 +++++++++---------- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/komga/src/flyway/resources/db/migration/postgresql/V20200810165912__thumbnails_part_3.sql b/komga/src/flyway/resources/db/migration/postgresql/V20200810165912__thumbnails_part_3.sql index 678ef804..541ad5ff 100644 --- a/komga/src/flyway/resources/db/migration/postgresql/V20200810165912__thumbnails_part_3.sql +++ b/komga/src/flyway/resources/db/migration/postgresql/V20200810165912__thumbnails_part_3.sql @@ -2,7 +2,6 @@ CREATE INDEX idx__thumbnail_book__book_id on THUMBNAIL_BOOK (BOOK_ID); -- Remove column THUMBNAIL from table MEDIA -PRAGMA foreign_keys= OFF; ALTER TABLE MEDIA RENAME TO _MEDIA_OLD; @@ -15,7 +14,7 @@ CREATE TABLE MEDIA LAST_MODIFIED_DATE timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, COMMENT varchar NULL, BOOK_ID varchar NOT NULL PRIMARY KEY, - PAGE_COUNT int NOT NULL DEFAULT false, + PAGE_COUNT integer NOT NULL DEFAULT 0, FOREIGN KEY (BOOK_ID) REFERENCES BOOK (ID) ); @@ -25,4 +24,3 @@ FROM _MEDIA_OLD; DROP TABLE _MEDIA_OLD; -PRAGMA foreign_keys= ON; diff --git a/komga/src/flyway/resources/db/migration/postgresql/V20200820154318__metadata_fields_part_3.sql b/komga/src/flyway/resources/db/migration/postgresql/V20200820154318__metadata_fields_part_3.sql index d792a51b..a6ae9d21 100644 --- a/komga/src/flyway/resources/db/migration/postgresql/V20200820154318__metadata_fields_part_3.sql +++ b/komga/src/flyway/resources/db/migration/postgresql/V20200820154318__metadata_fields_part_3.sql @@ -1,4 +1,3 @@ -PRAGMA foreign_keys= OFF; ALTER TABLE BOOK_METADATA RENAME TO _BOOK_METADATA_OLD; @@ -44,4 +43,3 @@ FROM _BOOK_METADATA_OLD; DROP TABLE _BOOK_METADATA_OLD; -PRAGMA foreign_keys= ON; diff --git a/komga/src/flyway/resources/db/migration/postgresql/V20230922143307__server_settings.sql b/komga/src/flyway/resources/db/migration/postgresql/V20230922143307__server_settings.sql index 9f918c4d..3ef044e3 100644 --- a/komga/src/flyway/resources/db/migration/postgresql/V20230922143307__server_settings.sql +++ b/komga/src/flyway/resources/db/migration/postgresql/V20230922143307__server_settings.sql @@ -9,6 +9,6 @@ VALUES ('DELETE_EMPTY_COLLECTIONS', ${delete-empty-collections}); INSERT INTO SERVER_SETTINGS VALUES ('DELETE_EMPTY_READLISTS', ${delete-empty-read-lists}); INSERT INTO SERVER_SETTINGS -VALUES ('REMEMBER_ME_KEY', hex(randomblob(32))); +VALUES ('REMEMBER_ME_KEY', md5(random()::text)); INSERT INTO SERVER_SETTINGS VALUES ('REMEMBER_ME_DURATION', 365); diff --git a/komga/src/flyway/resources/db/migration/postgresql/V20240614170012__user_kobo_role.sql b/komga/src/flyway/resources/db/migration/postgresql/V20240614170012__user_kobo_role.sql index 5c8e30e7..4be1387b 100644 --- a/komga/src/flyway/resources/db/migration/postgresql/V20240614170012__user_kobo_role.sql +++ b/komga/src/flyway/resources/db/migration/postgresql/V20240614170012__user_kobo_role.sql @@ -2,5 +2,5 @@ alter table "USER" add column ROLE_KOBO_SYNC boolean NOT NULL DEFAULT false; update "USER" -set ROLE_KOBO_SYNC = 1 -where ROLE_ADMIN = 1; +set ROLE_KOBO_SYNC = true +where ROLE_ADMIN = true; diff --git a/komga/src/flyway/resources/db/migration/postgresql/V20250108115503__user_roles.sql b/komga/src/flyway/resources/db/migration/postgresql/V20250108115503__user_roles.sql index 76aed22e..9e65aa4b 100644 --- a/komga/src/flyway/resources/db/migration/postgresql/V20250108115503__user_roles.sql +++ b/komga/src/flyway/resources/db/migration/postgresql/V20250108115503__user_roles.sql @@ -7,32 +7,31 @@ CREATE TABLE USER_ROLE ); insert into USER_ROLE -select id, "ADMIN" -from user -where ROLE_ADMIN = 1; +select id, 'ADMIN' +from "USER" +where ROLE_ADMIN = true; insert into USER_ROLE -select id, "KOREADER_SYNC" -from user -where ROLE_ADMIN = 1; +select id, 'KOREADER_SYNC' +from "USER" +where ROLE_ADMIN = true; insert into USER_ROLE -select id, "FILE_DOWNLOAD" -from user -where ROLE_FILE_DOWNLOAD = 1; +select id, 'FILE_DOWNLOAD' +from "USER" +where ROLE_FILE_DOWNLOAD = true; insert into USER_ROLE -select id, "PAGE_STREAMING" -from user -where ROLE_PAGE_STREAMING = 1; +select id, 'PAGE_STREAMING' +from "USER" +where ROLE_PAGE_STREAMING = true; insert into USER_ROLE -select id, "KOBO_SYNC" -from user -where ROLE_KOBO_SYNC = 1; +select id, 'KOBO_SYNC' +from "USER" +where ROLE_KOBO_SYNC = true; -- Remove columns ROLE_ADMIN, ROLE_FILE_DOWNLOAD, ROLE_PAGE_STREAMING, ROLE_KOBO_SYNC from "USER" -PRAGMA foreign_keys= OFF; create table USER_dg_tmp ( @@ -60,9 +59,7 @@ select ID, AGE_RESTRICTION_ALLOW_ONLY from "USER"; -drop table "USER"; +drop table "USER" CASCADE; alter table USER_dg_tmp rename to "USER"; - -PRAGMA foreign_keys= ON;