From a7b2ff1301bf151e05cd67f209668dd1b5855a2e Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 24 Jan 2012 18:33:33 +0100 Subject: [PATCH] [entropy.db] _migrateBaseinfoExtrainfo: fix foreign_keys usage, and drop all indexes Using pragma inside executescript() won't work and foreign_keys were kept enabled, resulting in extrainfo table being wiped. At the same time, dropping all the indexes before starting dramatically improves the execution speed. --- lib/entropy/db/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/entropy/db/__init__.py b/lib/entropy/db/__init__.py index 7ae3b6875..522d2b50f 100644 --- a/lib/entropy/db/__init__.py +++ b/lib/entropy/db/__init__.py @@ -5913,9 +5913,10 @@ class EntropyRepository(EntropyRepositoryBase): importance = 1, level = "warning") + self.dropAllIndexes() + self._cursor().execute("pragma foreign_keys = OFF").fetchall() self._cursor().executescript(""" BEGIN TRANSACTION; - PRAGMA foreign_keys = OFF; DROP TABLE IF EXISTS baseinfo_new_temp; CREATE TABLE baseinfo_new_temp ( @@ -5965,9 +5966,9 @@ class EntropyRepository(EntropyRepositoryBase): ALTER TABLE extrainfo_new_temp RENAME TO extrainfo; DROP TABLE flags; - PRAGMA foreign_keys = ON; COMMIT; """) + self._cursor().execute("pragma foreign_keys = ON").fetchall() self._setSetting("_baseinfo_extrainfo_2010", "1")