Fix initial setup bug

This commit is contained in:
Tim Bentley 2011-08-27 16:02:45 +01:00
parent 611577577f
commit c1a648900f
3 changed files with 19 additions and 13 deletions

View File

@ -90,7 +90,7 @@ def upgrade_db(url, upgrade):
version_meta = session.query(Metadata).get(u'version') version_meta = session.query(Metadata).get(u'version')
if version_meta is None: if version_meta is None:
version_meta = Metadata.populate(key=u'version', value=u'0') version_meta = Metadata.populate(key=u'version', value=u'0')
version = 0 version = 0 if tables else upgrade.__version__;
else: else:
version = int(version_meta.value) version = int(version_meta.value)
if version > upgrade.__version__: if version > upgrade.__version__:

View File

@ -41,6 +41,7 @@ def upgrade_setup(metadata):
upgrade process. If you want to drop a table, you need to remove it from upgrade process. If you want to drop a table, you need to remove it from
here, and add it to your upgrade function. here, and add it to your upgrade function.
""" """
try:
tables = { tables = {
u'authors': Table(u'authors', metadata, autoload=True), u'authors': Table(u'authors', metadata, autoload=True),
u'media_files': Table(u'media_files', metadata, autoload=True), u'media_files': Table(u'media_files', metadata, autoload=True),
@ -50,6 +51,8 @@ def upgrade_setup(metadata):
u'authors_songs': Table(u'authors_songs', metadata, autoload=True), u'authors_songs': Table(u'authors_songs', metadata, autoload=True),
u'songs_topics': Table(u'songs_topics', metadata, autoload=True) u'songs_topics': Table(u'songs_topics', metadata, autoload=True)
} }
except:
tables = None
return tables return tables

View File

@ -40,9 +40,12 @@ def upgrade_setup(metadata):
upgrade process. If you want to drop a table, you need to remove it from upgrade process. If you want to drop a table, you need to remove it from
here, and add it to your upgrade function. here, and add it to your upgrade function.
""" """
try:
tables = { tables = {
u'songusage_data': Table(u'songusage_data', metadata, autoload=True) u'songusage_data': Table(u'songusage_data', metadata, autoload=True)
} }
except:
tables = None
return tables return tables