From 8ad76179ebfb33e1a1d5788c3518e62cd525cd6d Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Fri, 11 Dec 2015 22:27:15 +0000 Subject: [PATCH] Moving new table definition into migration section This ensures that upgrades from existing databases will be seamless --- resources/data/models/Catalogue.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/data/models/Catalogue.py b/resources/data/models/Catalogue.py index b6ac534..6c59cba 100644 --- a/resources/data/models/Catalogue.py +++ b/resources/data/models/Catalogue.py @@ -53,10 +53,6 @@ def __init__(self, database_path): CREATE TABLE cache_status ( etag TEXT ) ''') - database.execute(''' - CREATE TABLE cookies ( - cookieblob TEXT - )''') database.execute(''' CREATE TABLE auth ( token TEXT @@ -127,6 +123,12 @@ def __init__(self, database_path): database.commit() else: database = sqlite3.connect(database_path) + # Deviations from the original schema should be + # defined here so that upgrades will work correctly + database.execute(''' + CREATE TABLE IF NOT EXISTS cookies ( + cookieblob TEXT + )''') database.row_factory = sqlite3.Row self.database = database