diff --git a/komga/src/flyway/resources/db/migration/sqlite/V20220128152310__page_hash.sql b/komga/src/flyway/resources/db/migration/sqlite/V20220128152310__page_hash.sql index 632855ef2..efaa0d1d0 100644 --- a/komga/src/flyway/resources/db/migration/sqlite/V20220128152310__page_hash.sql +++ b/komga/src/flyway/resources/db/migration/sqlite/V20220128152310__page_hash.sql @@ -19,8 +19,8 @@ CREATE TABLE PAGE_HASH_THUMBNAIL PRIMARY KEY (HASH, MEDIA_TYPE, SIZE) ); -DELETE -FROM MEDIA_PAGE +UPDATE MEDIA_PAGE +SET FILE_HASH = '' WHERE BOOK_ID IN ( SELECT DISTINCT m.BOOK_ID FROM MEDIA m diff --git a/komga/src/flyway/resources/db/migration/sqlite/V20220208193203__fix_books_with_missing_pages.sql b/komga/src/flyway/resources/db/migration/sqlite/V20220208193203__fix_books_with_missing_pages.sql new file mode 100644 index 000000000..5bbb95db6 --- /dev/null +++ b/komga/src/flyway/resources/db/migration/sqlite/V20220208193203__fix_books_with_missing_pages.sql @@ -0,0 +1,8 @@ +UPDATE MEDIA +SET STATUS = 'OUTDATED' +WHERE BOOK_ID IN ( + SELECT M.BOOK_ID + FROM MEDIA M + LEFT JOIN MEDIA_PAGE MP on M.BOOK_ID = MP.BOOK_ID + GROUP BY M.BOOK_ID, M.PAGE_COUNT + HAVING M.PAGE_COUNT <> count(MP.BOOK_ID)); diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/FlywayConfiguration.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/FlywayConfiguration.kt new file mode 100644 index 000000000..01b68bf25 --- /dev/null +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/FlywayConfiguration.kt @@ -0,0 +1,19 @@ +package org.gotson.komga.infrastructure.datasource + +import org.flywaydb.core.Flyway +import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +// TODO: remove after March 2022 - added to fix the 0.149.0 changed migration +// We should not rely on flyway repair on a permanent basis! +@Configuration +class FlywayConfiguration { + + @Bean + fun cleanMigrateStrategy() = + FlywayMigrationStrategy { flyway: Flyway -> + flyway.repair() + flyway.migrate() + } +}