mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 08:10:59 +00:00
Fix account list join primary key
This commit is contained in:
parent
5f2c59dee3
commit
ec246a50ed
1 changed files with 16 additions and 0 deletions
|
@ -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
|
return migrator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue