Skip to content

Commit

Permalink
Change order of table updates in SQLCodeMigrations
Browse files Browse the repository at this point in the history
Bookmark table is usually relatively small compared to post table. So we are making sure the ids are updated there first.
  • Loading branch information
msasikanth committed Apr 14, 2024
1 parent a96622a commit 46e362f
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,24 @@ 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
)
}

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
)
Expand All @@ -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
)
Expand Down

0 comments on commit 46e362f

Please sign in to comment.