Fix account list join primary key

This commit is contained in:
Justin Mazzocchi 2021-02-08 08:19:21 -08:00
parent 5f2c59dee3
commit ec246a50ed
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C

View file

@ -268,6 +268,22 @@ extension ContentDatabase {
}
}
migrator.registerMigration("1.0.0-pk-fix") { db in
try db.create(table: "new_accountListJoin") { t in
t.column("accountListId", .text).indexed().notNull()
.references("accountList", onDelete: .cascade)
t.column("accountId", .text).indexed().notNull()
.references("accountRecord", onDelete: .cascade)
t.column("order", .integer).notNull()
t.primaryKey(["accountListId", "accountId"], onConflict: .replace)
}
try db.execute(sql: "INSERT INTO new_accountListJoin SELECT * FROM accountListJoin")
try db.drop(table: "accountListJoin")
try db.rename(table: "new_accountListJoin", to: "accountListJoin")
}
return migrator
}
}