aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migrations.py
diff options
context:
space:
mode:
authortilly-Q <nattilypigeonfowl@gmail.com>2013-10-09 17:11:41 -0400
committertilly-Q <nattilypigeonfowl@gmail.com>2013-10-09 17:11:41 -0400
commite5196ff0006da687ae31466d8c8e384c6be05ccd (patch)
tree70a1b7545ea5e4103928f3afbe3d53bd0e528528 /mediagoblin/db/migrations.py
parenta4609dd32b3b0db2f2317b8b407b515b41bd0127 (diff)
downloadmediagoblin-e5196ff0006da687ae31466d8c8e384c6be05ccd.tar.lz
mediagoblin-e5196ff0006da687ae31466d8c8e384c6be05ccd.tar.xz
mediagoblin-e5196ff0006da687ae31466d8c8e384c6be05ccd.zip
I made some changes in this commit to help out with other people trying to work
around the SQLite problems with Alter table. I added a new function to migration_tools (replace_table) which does all the work I did in my migration of core__users, but is now usable for other migrations.
Diffstat (limited to 'mediagoblin/db/migrations.py')
-rw-r--r--mediagoblin/db/migrations.py25
1 files changed, 4 insertions, 21 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index a1a7c576..6dae79db 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -27,7 +27,8 @@ from migrate.changeset.constraint import UniqueConstraint
from mediagoblin.db.extratypes import JSONEncoded, MutationDict
-from mediagoblin.db.migration_tools import RegisterMigration, inspect_table
+from mediagoblin.db.migration_tools import (RegisterMigration, inspect_table,
+ replace_table)
from mediagoblin.db.models import (MediaEntry, Collection, MediaComment, User,
Privilege)
@@ -683,7 +684,7 @@ def create_moderation_tables(db):
db.commit()
- # And then, once the information is taken from the is_admin & status columns
+ # And then, once the information is taken from is_admin & status columns
# we drop all of the vestigial columns from the User table.
#--------------------------------------------------------------------------
if db.bind.url.drivername == 'sqlite':
@@ -694,25 +695,7 @@ def create_moderation_tables(db):
User_vR1.__table__.create(db.bind)
db.commit()
new_user_table = inspect_table(metadata, 'rename__users')
- for row in db.execute(user_table.select()):
- db.execute(new_user_table.insert().values(
- username=row.username,
- email=row.email,
- pw_hash=row.pw_hash,
- created=row.created,
- wants_comment_notification=row.wants_comment_notification,
- wants_notifications=row.wants_notifications,
- license_preference=row.license_preference,
- url=row.url,
- bio=row.bio,
- uploaded=row.uploaded,
- upload_limit=row.upload_limit))
-
- db.commit()
- user_table.drop()
-
- db.commit()
- new_user_table.rename("core__users")
+ replace_table(db,user_table, new_user_table)
else:
# If the db is not run using SQLite, this process is much simpler ~~~~~