A few more tweaks as requested by Andreas.

This commit is contained in:
Raoul Snyman 2011-08-25 22:14:02 +02:00
parent bcf9b174ff
commit 4b1ce7102e
2 changed files with 16 additions and 3 deletions

View File

@ -54,12 +54,24 @@ def upgrade_setup(metadata):
def upgrade_1(session, metadata, tables): def upgrade_1(session, metadata, tables):
"""
Version 1 upgrade.
This upgrade removes the many-to-many relationship between songs and
media_files and replaces it with a one-to-many, which is far more
representative of the real relationship between the two entities.
In order to facilitate this one-to-many relationship, a song_id column is
added to the media_files table, and a weight column so that the media
files can be ordered.
"""
Table(u'media_files_songs', metadata, autoload=True).drop(checkfirst=True) Table(u'media_files_songs', metadata, autoload=True).drop(checkfirst=True)
Column(u'song_id', types.Integer(), default=None)\ Column(u'song_id', types.Integer(), default=None)\
.create(table=tables[u'media_files'], populate_default=True) .create(table=tables[u'media_files'], populate_default=True)
Column(u'weight', types.Integer(), default=0)\ Column(u'weight', types.Integer(), default=0)\
.create(table=tables[u'media_files'], populate_default=True) .create(table=tables[u'media_files'], populate_default=True)
if metadata.bind.url.get_dialect().name != 'sqlite': if metadata.bind.url.get_dialect().name != 'sqlite':
# SQLite doesn't support ALTER TABLE ADD CONSTRAINT
ForeignKeyConstraint([u'song_id'], [u'songs.id'], ForeignKeyConstraint([u'song_id'], [u'songs.id'],
table=tables[u'media_files']).create() table=tables[u'media_files']).create()

View File

@ -46,14 +46,14 @@ VERS = {
'sqlalchemy': '0.5', 'sqlalchemy': '0.5',
# pyenchant 1.6 required on Windows # pyenchant 1.6 required on Windows
'enchant': '1.6' if is_win else '1.3' 'enchant': '1.6' if is_win else '1.3'
} }
# pywin32 # pywin32
WIN32_MODULES = [ WIN32_MODULES = [
'win32com', 'win32com',
'win32ui', 'win32ui',
'pywintypes', 'pywintypes',
] ]
MODULES = [ MODULES = [
'PyQt4', 'PyQt4',
@ -72,7 +72,8 @@ MODULES = [
'enchant', 'enchant',
'BeautifulSoup', 'BeautifulSoup',
'mako', 'mako',
] 'migrate',
]
OPTIONAL_MODULES = [ OPTIONAL_MODULES = [