aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-08-07 14:45:08 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-08-07 15:01:09 -0500
commit3a8d0e145ee2de7a72693789f66cdbf6b5b53b30 (patch)
tree54897153ac5831314b727f60755f22558f4893e5
parentbb12fb807e59cbe124c32c0b4fa2a74e0b81aade (diff)
downloadmediagoblin-3a8d0e145ee2de7a72693789f66cdbf6b5b53b30.tar.lz
mediagoblin-3a8d0e145ee2de7a72693789f66cdbf6b5b53b30.tar.xz
mediagoblin-3a8d0e145ee2de7a72693789f66cdbf6b5b53b30.zip
Document both migrations, comment out old migration
-rw-r--r--mediagoblin/db/migrations.py44
1 files changed, 35 insertions, 9 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 3bcf2a65..d8a6d1ce 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -793,21 +793,47 @@ def fix_privilege_user_association_table(db):
@RegisterMigration(22, MIGRATIONS)
def add_index_username_field(db):
"""
- This indexes the User.username field which is frequently queried
- for example a user logging in. This solves the issue #894
- """
- metadata = MetaData(bind=db.bind)
- user_table = inspect_table(metadata, "core__users")
+ This migration has been found to be doing the wrong thing. See
+ the documentation in migration 23 (revert_username_index) below
+ which undoes this for those databases that did run this migration.
- new_index = Index("ix_core__users_uploader", user_table.c.username)
- new_index.create()
-
- db.commit()
+ Old description:
+ This indexes the User.username field which is frequently queried
+ for example a user logging in. This solves the issue #894
+ """
+ ## This code is left commented out *on purpose!*
+ ##
+ ## We do not normally allow commented out code like this in
+ ## MediaGoblin but this is a special case: since this migration has
+ ## been nullified but with great work to set things back below,
+ ## this is commented out for historical clarity.
+ #
+ # metadata = MetaData(bind=db.bind)
+ # user_table = inspect_table(metadata, "core__users")
+ #
+ # new_index = Index("ix_core__users_uploader", user_table.c.username)
+ # new_index.create()
+ #
+ # db.commit()
+ pass
@RegisterMigration(23, MIGRATIONS)
def revert_username_index(db):
"""
+ Revert the stuff we did in migration 22 above.
+
+ There were a couple of problems with what we did:
+ - There was never a need for this migration! The unique
+ constraint had an implicit b-tree index, so it wasn't really
+ needed. (This is my (Chris Webber's) fault for suggesting it
+ needed to happen without knowing what's going on... my bad!)
+ - On top of that, databases created after the models.py was
+ changed weren't the same as those that had been run through
+ migration 22 above.
+
+ As such, we're setting things back to the way they were before,
+ but as it turns out, that's tricky to do!
"""
metadata = MetaData(bind=db.bind)
user_table = inspect_table(metadata, "core__users")