Fix local account id primary key issue

This commit is contained in:
Justin Mazzocchi 2021-03-30 23:19:14 -07:00
parent 9c2c46ed82
commit 107de97802
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
1 changed files with 23 additions and 0 deletions

View File

@ -44,6 +44,29 @@ extension IdentityDatabase {
}
}
migrator.registerMigration("1.2.0-pk-fix") { db in
try db.create(table: "new_account") { t in
t.column("id", .text).notNull()
t.column("identityId", .text).notNull()
.references("identityRecord", onDelete: .cascade)
t.column("username", .text).notNull()
t.column("displayName", .text).notNull()
t.column("url", .text).notNull()
t.column("avatar", .text).notNull()
t.column("avatarStatic", .text).notNull()
t.column("header", .text).notNull()
t.column("headerStatic", .text).notNull()
t.column("emojis", .blob).notNull()
t.column("followRequestCount", .integer).notNull()
t.primaryKey(["id", "identityId"], onConflict: .replace)
}
try db.execute(sql: "INSERT INTO new_account SELECT * FROM account")
try db.drop(table: "account")
try db.rename(table: "new_account", to: "account")
}
return migrator
}
}