Disable foreign key checks during schema modifications
Otherwise renaming a table causes existing foreign keys to be renamed.
This commit is contained in:
parent
8933e3b586
commit
6844deba60
1 changed files with 24 additions and 20 deletions
|
@ -117,9 +117,9 @@ Zotero.Schema = new function(){
|
|||
yield Zotero.DB.backupDatabase(userdata, true);
|
||||
}
|
||||
|
||||
yield Zotero.DB.queryAsync("PRAGMA foreign_keys = false");
|
||||
try {
|
||||
var updated = yield Zotero.DB.executeTransaction(function* (conn) {
|
||||
yield Zotero.DB.queryAsync("PRAGMA defer_foreign_keys = true");
|
||||
|
||||
var updated = yield _updateSchema('system');
|
||||
|
||||
// Update custom tables if they exist so that changes are in
|
||||
|
@ -137,6 +137,10 @@ Zotero.Schema = new function(){
|
|||
|
||||
return updated;
|
||||
}.bind(this));
|
||||
}
|
||||
finally {
|
||||
yield Zotero.DB.queryAsync("PRAGMA foreign_keys = true");
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
// Upgrade seems to have been a success -- delete any previous backups
|
||||
|
|
Loading…
Reference in a new issue