From e5367127eaec2bc30d2ba6d433ea0d987bbe0601 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sun, 1 May 2016 14:46:51 -0400 Subject: [PATCH] Adds migration path from pre-release database to stable (previously unsupported) (#586) --- eos/db/migrations/upgrade14.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 eos/db/migrations/upgrade14.py diff --git a/eos/db/migrations/upgrade14.py b/eos/db/migrations/upgrade14.py new file mode 100644 index 000000000..8b39947b2 --- /dev/null +++ b/eos/db/migrations/upgrade14.py @@ -0,0 +1,19 @@ +""" +Migration 14 + +- This should take care of issue #586. +""" + +import sqlalchemy + +def upgrade(saveddata_engine): + if saveddata_engine.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='fighters'").scalar() == 'fighters': + # Fighters table exists + try: + saveddata_engine.execute("SELECT active FROM fighters LIMIT 1") + except sqlalchemy.exc.DatabaseError: + # if we don't have the active column, we are on an old pre-release version. Drop the tables and move on + # (they will be recreated) + + saveddata_engine.execute("DROP TABLE fighters") + saveddata_engine.execute("DROP TABLE fightersAbilities") \ No newline at end of file