From b2cf4b8aa5ca417d668192ba9ea45790a9392668 Mon Sep 17 00:00:00 2001 From: blitzman Date: Mon, 28 Nov 2016 21:07:09 -0500 Subject: [PATCH] Delete broken references to in commandFits (#844) --- eos/db/migrations/upgrade19.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 eos/db/migrations/upgrade19.py diff --git a/eos/db/migrations/upgrade19.py b/eos/db/migrations/upgrade19.py new file mode 100644 index 000000000..4d93edc7c --- /dev/null +++ b/eos/db/migrations/upgrade19.py @@ -0,0 +1,20 @@ +""" +Migration 19 + +- Deletes broken references to fits from the commandFits table (see GH issue #844) +""" + +import sqlalchemy + + +def upgrade(saveddata_engine): + from eos.db import saveddata_session + + sql = """ + DELETE FROM commandFits + WHERE boosterID NOT IN (select ID from fits) + OR boostedID NOT IN (select ID from fits) + """ + + saveddata_session.execute(sql) + saveddata_session.commit()