From 84b1e0ac41d7bf5a80e2b0b6b39e974910fe0700 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Thu, 2 Jul 2015 19:34:02 -0400 Subject: [PATCH] Migrate boosters table to new schema that drops the UNIQUE constraint (causes issues and is unneeded) --- eos/db/migrations/upgrade9.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 eos/db/migrations/upgrade9.py diff --git a/eos/db/migrations/upgrade9.py b/eos/db/migrations/upgrade9.py new file mode 100644 index 000000000..ae7b66ad5 --- /dev/null +++ b/eos/db/migrations/upgrade9.py @@ -0,0 +1,23 @@ +""" +Migration 9 + +Effectively drops UNIQUE constraint from boosters table. SQLite does not support +this, so we have to copy the table to the updated schema and then rename it +""" + +tmpTable = """ +CREATE TABLE boostersTemp ( + 'ID' INTEGER NOT NULL, + 'itemID' INTEGER, + 'fitID' INTEGER NOT NULL, + 'active' BOOLEAN, + PRIMARY KEY(ID), + FOREIGN KEY('fitID') REFERENCES fits ('ID') +) +""" + +def upgrade(saveddata_engine): + saveddata_engine.execute(tmpTable) + saveddata_engine.execute("INSERT INTO boostersTemp (ID, itemID, fitID, active) SELECT ID, itemID, fitID, active FROM boosters") + saveddata_engine.execute("DROP TABLE boosters") + saveddata_engine.execute("ALTER TABLE boostersTemp RENAME TO boosters")