Use PRAGMA legacy_alter_table=ON
for existing schema updates
This won't make a difference until we update Firefox and get a new SQLite version, but at that point the existing schema update steps that recreate tables by renaming the old table would result in broken foreign keys. This patch will make sure that newer SQLite versions will use the legacy behavior for the existing steps, and going forward schema update steps that want to recreate tables will need to create a new table, migrate the data, delete the old table, and rename the new one into place.
This commit is contained in:
parent
eac98d1c2e
commit
ddc7be75c7
1 changed files with 14 additions and 0 deletions
|
@ -2590,6 +2590,12 @@ Zotero.Schema = new function(){
|
|||
|
||||
Zotero.DB.requireTransaction();
|
||||
|
||||
// Use old rename/FK behavior from SQLite <3.25
|
||||
// https://stackoverflow.com/a/57275538
|
||||
if (fromVersion <= 113) {
|
||||
yield Zotero.DB.queryAsync("PRAGMA legacy_alter_table=ON");
|
||||
}
|
||||
|
||||
// Step through version changes until we reach the current version
|
||||
//
|
||||
// Each block performs the changes necessary to move from the
|
||||
|
@ -3303,6 +3309,14 @@ Zotero.Schema = new function(){
|
|||
}
|
||||
}
|
||||
|
||||
else if (i == 118) {
|
||||
// Switch to new rename/FK behavior. All further table rebuilds must create a new
|
||||
// table with a temporary name, do an INSERT...SELECT (with default/missing values
|
||||
// as appropriate), delete the old table, and rename the new one back to the
|
||||
// original name. https://stackoverflow.com/a/57275538
|
||||
yield Zotero.DB.queryAsync("PRAGMA legacy_alter_table=OFF");
|
||||
}
|
||||
|
||||
// If breaking compatibility or doing anything dangerous, clear minorUpdateFrom
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue