Commit 6de8f506 authored by Thomas Goirand's avatar Thomas Goirand

* Add SQLite 3.26+ patch from Ubuntu (Closes: #915938). Thanks to Corey

    Bryant for forwarding the patch.
parent 92f526c4
......@@ -6,6 +6,8 @@ migrate (0.11.0-4) unstable; urgency=medium
[ Thomas Goirand ]
* Move the package in Salsa from /openstack-team/python to libs:
- Update VCS fields accordingly.
* Add SQLite 3.26+ patch from Ubuntu (Closes: #915938). Thanks to Corey
Bryant for forwarding the patch.
-- Thomas Goirand <zigo@debian.org> Mon, 10 Dec 2018 09:55:26 +0100
......
......@@ -2,3 +2,4 @@ use-local-intersphinx.patch
keep_empty_modules.patch
disable_issuetracker.patch
remove-tempest-lib-build-depends-from-upstream.patch
use-legacy-alter-sqlite.patch
Description: Use legacy_alter_table ON in sqlite recreate_table
Author: Corey Bryant <corey.bryant@canonical.com>
Date: Fri, 7 Dec 2018 13:49:20 -0500
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use "PRAGMA legacy_alter_table = ON" with sqlite >= 3.26 when
using "ALTER TABLE RENAME TO migration_tmp" to maintain legacy
behavior.
.
As of sqlite version 3.26, when a table is renamed using
"ALTER TABLE RENAME TO", REFERENCES clauses that refer to the
table will be updated. To maintain legacy (3.24 and earlier)
behavior, "PRAGMA legacy_alter_table" can be set to true and
"PRAGMA foreign_keys" can be set to false. [1]
.
[1] https://www.sqlite.org/src/info/ae9638e9c0ad0c36
.
Thanks to "László Böszörményi (GCS)" <gcs@debian.org> for
providing the code for this patch, which has since been
slightly modified.
Change-Id: I539988ab2ad6df6c8f423ecec15364ad8fcc7267
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/nova/+bug/1807262
Bug-Debian: https://bugs.debian.org/916046
Last-Update: 2018-12-10
diff --git a/migrate/changeset/databases/sqlite.py b/migrate/changeset/databases/sqlite.py
index 92d42f2..568a329 100644
--- a/migrate/changeset/databases/sqlite.py
+++ b/migrate/changeset/databases/sqlite.py
@@ -96,8 +96,15 @@ class SQLiteHelper(SQLiteCommon):
if omit_constraints is None or cons.name not in omit_constraints
])
+ tup = sqlite3.sqlite_version_info
+ if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 26):
+ self.append('PRAGMA legacy_alter_table = ON')
+ self.execute()
self.append('ALTER TABLE %s RENAME TO migration_tmp' % table_name)
self.execute()
+ if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 26):
+ self.append('PRAGMA legacy_alter_table = OFF')
+ self.execute()
insertion_string = self._modify_table(table, column, delta)
--
2.19.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment