From 46e362f5ad01ccff6c72c8f303b8464afa4d34b1 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Sun, 14 Apr 2024 07:28:48 +0530 Subject: [PATCH] Change order of table updates in `SQLCodeMigrations` Bookmark table is usually relatively small compared to post table. So we are making sure the ids are updated there first. --- .../rss/reader/database/migrations/SQLCodeMigrations.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt index 724d523c6..4faf115c0 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt @@ -61,14 +61,14 @@ object SQLCodeMigrations { driver.execute( identifier = null, - sql = "UPDATE post SET sourceId = '$newFeedId' WHERE sourceId = '$oldFeedId'", + sql = "UPDATE bookmark SET sourceId = '$newFeedId' WHERE sourceId = '$oldFeedId'", parameters = 0, binders = null ) driver.execute( identifier = null, - sql = "UPDATE bookmark SET sourceId = '$newFeedId' WHERE sourceId = '$oldFeedId'", + sql = "UPDATE post SET sourceId = '$newFeedId' WHERE sourceId = '$oldFeedId'", parameters = 0, binders = null ) @@ -76,10 +76,9 @@ object SQLCodeMigrations { private fun migratePostLinkIdsToUuid(driver: SqlDriver, oldPostId: String) { val newPostId = nameBasedUuidOf(oldPostId).toString() - driver.execute( identifier = null, - sql = "UPDATE post SET id = '$newPostId' WHERE id = '$oldPostId'", + sql = "UPDATE bookmark SET id = '$newPostId' WHERE id = '$oldPostId'", parameters = 0, binders = null ) @@ -93,7 +92,7 @@ object SQLCodeMigrations { driver.execute( identifier = null, - sql = "UPDATE bookmark SET id = '$newPostId' WHERE id = '$oldPostId'", + sql = "UPDATE post SET id = '$newPostId' WHERE id = '$oldPostId'", parameters = 0, binders = null )