~tomasgroth/openlp/song-key

« back to all changes in this revision

Viewing changes to openlp/plugins/songs/lib/upgrade.py

  • Committer: Tomas Groth
  • Date: 2018-09-02 19:04:58 UTC
  • Revision ID: tomasgroth@yahoo.dk-20180902190458-tqbvx9ydmla4chja
Add key to song DB and songeditform.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
from openlp.core.lib.db import PathType, get_upgrade_op
37
37
 
38
38
log = logging.getLogger(__name__)
39
 
__version__ = 7
 
39
__version__ = 8
40
40
 
41
41
 
42
42
# TODO: When removing an upgrade path the ftw-data needs updating to the minimum supported version
191
191
        else:
192
192
            op.drop_constraint('media_files', 'foreignkey')
193
193
            op.drop_column('media_files', 'filenames')
 
194
 
 
195
 
 
196
def upgrade_8(session, metadata):
 
197
    """
 
198
    Version 8 upgrade.
 
199
 
 
200
    This upgrade adds a song key the songs table
 
201
    """
 
202
    op = get_upgrade_op(session)
 
203
    songs_table = Table('songs', metadata, autoload=True)
 
204
    if 'song_key' not in [col.name for col in songs_table.c.values()]:
 
205
        op.add_column('songs', Column('song_key', types.Unicode(5)))
 
206
    else:
 
207
        log.warning('Skipping upgrade_8 step of upgrading the song db')