return Table(table_name, metadata, autoload=True,
autoload_with=metadata.bind)
-def replace_table(db, old_table,replacement_table):
- """A function to fully replace a current table with a new one for migrati-
+def replace_table_hack(db, old_table, replacement_table):
+ """
+ A function to fully replace a current table with a new one for migrati-
-ons. This is necessary because some changes are made tricky in some situa-
-tion, for example, dropping a boolean column in sqlite is impossible w/o
this method
inspect_table
:param replacement_table A ref to the new table, gotten through
- inspect_table"""
+ inspect_table
+
+ Users are encouraged to sqlalchemy-migrate replace table solutions, unless
+ that is not possible... in which case, this solution works,
+ at least for sqlite.
+ """
surviving_columns = replacement_table.columns.keys()
old_table_name = old_table.name
for row in db.execute(select(
from mediagoblin.db.extratypes import JSONEncoded, MutationDict
-from mediagoblin.db.migration_tools import (RegisterMigration, inspect_table,
- replace_table)
+from mediagoblin.db.migration_tools import (
+ RegisterMigration, inspect_table, replace_table_hack)
from mediagoblin.db.models import (MediaEntry, Collection, MediaComment, User,
Privilege)
User_vR1.__table__.create(db.bind)
db.commit()
new_user_table = inspect_table(metadata, 'rename__users')
- replace_table(db,user_table, new_user_table)
+ replace_table_hack(db, user_table, new_user_table)
else:
# If the db is not run using SQLite, this process is much simpler ~~~~~