aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migration_tools.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-10-10 14:22:38 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-10-10 14:22:38 -0500
commit0c875e1e96b77892bd3f9bd5a91959c57ab7b91c (patch)
tree1b60d151d16d2b1af5c0f1520ce41b4aad290f08 /mediagoblin/db/migration_tools.py
parent454a2c16bdb8849805f338f325eb5a481f1cc826 (diff)
downloadmediagoblin-0c875e1e96b77892bd3f9bd5a91959c57ab7b91c.tar.lz
mediagoblin-0c875e1e96b77892bd3f9bd5a91959c57ab7b91c.tar.xz
mediagoblin-0c875e1e96b77892bd3f9bd5a91959c57ab7b91c.zip
Renaming replace_table to replace_table_hack and documenting why it's a hack
We'd still prefer people use other solutions when possible! This commit sponsored by Michał Masłowski. Thank you!
Diffstat (limited to 'mediagoblin/db/migration_tools.py')
-rw-r--r--mediagoblin/db/migration_tools.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mediagoblin/db/migration_tools.py b/mediagoblin/db/migration_tools.py
index 6b51025e..e39070c3 100644
--- a/mediagoblin/db/migration_tools.py
+++ b/mediagoblin/db/migration_tools.py
@@ -288,8 +288,9 @@ def inspect_table(metadata, table_name):
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
@@ -298,7 +299,12 @@ def replace_table(db, old_table,replacement_table):
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(