Try to prevent older versions of OpenLP from deleting newer Bibles due to a change in the metadata names.

This commit is contained in:
Raoul Snyman 2012-04-22 23:07:39 +02:00
parent 0f1bca77b4
commit 85d48705fc

View File

@ -29,7 +29,7 @@ The :mod:`upgrade` module provides a way for the database and schema that is the
backend for the Bibles plugin backend for the Bibles plugin
""" """
from sqlalchemy import Table, update, delete, or_ from sqlalchemy import Table, select, update, insert, or_
__version__ = 1 __version__ = 1
@ -60,16 +60,27 @@ def upgrade_1(session, metadata, tables):
.where(or_(metadata_table.c.key == u'bookname language', .where(or_(metadata_table.c.key == u'bookname language',
metadata_table.c.key == u'Bookname language'))\ metadata_table.c.key == u'Bookname language'))\
.values(key=u'book_name_language')) .values(key=u'book_name_language'))
# Rename "Copyright" to "copyright" # Copy "Copyright" to "copyright"
session.execute(update(metadata_table)\ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
.where(metadata_table.c.key == u'Copyright').values(key=u'copyright')) session.execute(insert(metadata_table).values(
# Rename "Version" to "name" ("version" used by upgrade system) key=u'copyright',
session.execute(update(metadata_table)\ value=select(metadata_table, metadata_table.c.key == u'Copyright')\
.where(metadata_table.c.key == u'Version').values(key=u'name')) .as_scalar()
# Rename "Permissions" to "permissions" ))
session.execute(update(metadata_table)\ # Copy "Version" to "name" ("version" used by upgrade system)
.where(metadata_table.c.key == u'Permissions')\ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
.values(key=u'permissions')) session.execute(insert(metadata_table).values(
key=u'name',
value=select(metadata_table, metadata_table.c.key == u'Version')\
.as_scalar()
))
# Copy "Permissions" to "permissions"
# TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
session.execute(insert(metadata_table).values(
key=u'permissions',
value=select(metadata_table, metadata_table.c.key == u'Permissions')\
.as_scalar()
))
session.execute(update(metadata_table)\ session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'download source')\ .where(metadata_table.c.key == u'download source')\
.values(key=u'download_source')) .values(key=u'download_source'))
@ -85,6 +96,7 @@ def upgrade_1(session, metadata, tables):
session.execute(update(metadata_table)\ session.execute(update(metadata_table)\
.where(metadata_table.c.key == u'proxy password')\ .where(metadata_table.c.key == u'proxy password')\
.values(key=u'proxy_password')) .values(key=u'proxy_password'))
session.execute(delete(metadata_table)\ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
.where(metadata_table.c.key == u'dbversion')) #session.execute(delete(metadata_table)\
# .where(metadata_table.c.key == u'dbversion'))
session.commit() session.commit()