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')
if version_meta is None:
version_meta = Metadata.populate(key=u'version', value=u'0')
version = 0
version = 0 if tables else upgrade.__version__;
else:
version = int(version_meta.value)
if version > upgrade.__version__:

View File

@ -41,15 +41,18 @@ def upgrade_setup(metadata):
upgrade process. If you want to drop a table, you need to remove it from
here, and add it to your upgrade function.
"""
tables = {
u'authors': Table(u'authors', metadata, autoload=True),
u'media_files': Table(u'media_files', metadata, autoload=True),
u'song_books': Table(u'song_books', metadata, autoload=True),
u'songs': Table(u'songs', metadata, autoload=True),
u'topics': Table(u'topics', metadata, autoload=True),
u'authors_songs': Table(u'authors_songs', metadata, autoload=True),
u'songs_topics': Table(u'songs_topics', metadata, autoload=True)
}
try:
tables = {
u'authors': Table(u'authors', metadata, autoload=True),
u'media_files': Table(u'media_files', metadata, autoload=True),
u'song_books': Table(u'song_books', metadata, autoload=True),
u'songs': Table(u'songs', metadata, autoload=True),
u'topics': Table(u'topics', metadata, autoload=True),
u'authors_songs': Table(u'authors_songs', metadata, autoload=True),
u'songs_topics': Table(u'songs_topics', metadata, autoload=True)
}
except:
tables = None
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
here, and add it to your upgrade function.
"""
tables = {
u'songusage_data': Table(u'songusage_data', metadata, autoload=True)
}
try:
tables = {
u'songusage_data': Table(u'songusage_data', metadata, autoload=True)
}
except:
tables = None
return tables