aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-08-07 16:29:45 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-08-07 16:29:45 -0500
commite6288a68e1d08538e40bf88ba8bcf3ac242decda (patch)
tree739f98e37c200fe6432e317cdf2641c4b93f0b67
parent3a8d0e145ee2de7a72693789f66cdbf6b5b53b30 (diff)
downloadmediagoblin-e6288a68e1d08538e40bf88ba8bcf3ac242decda.tar.lz
mediagoblin-e6288a68e1d08538e40bf88ba8bcf3ac242decda.tar.xz
mediagoblin-e6288a68e1d08538e40bf88ba8bcf3ac242decda.zip
Only add the constraint if we need to. Catch an exception if we don't.
Also, updating the comment about sqlite being crazy :)
-rw-r--r--mediagoblin/db/migrations.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index d8a6d1ce..6ca10b57 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -860,8 +860,8 @@ def revert_username_index(db):
replace_table_hack(db, user_table, new_user_table)
else:
- # If the db is not run using SQLite, this process is much simpler...
- # ...as usual ;)
+ # If the db is not run using SQLite, we don't need to do crazy
+ # table copying.
# Remove whichever of the not-used indexes are in place
if u'ix_core__users_uploader' in indexes:
@@ -872,9 +872,13 @@ def revert_username_index(db):
index.drop()
db.commit()
- # Add the unique constraint
- constraint = UniqueConstraint(
- 'username', table=user_table)
- constraint.create()
+ try:
+ # Add the unique constraint
+ constraint = UniqueConstraint(
+ 'username', table=user_table)
+ constraint.create()
+ except ProgrammingError:
+ # constraint already exists, no need to add
+ pass
db.commit()