Only add the constraint if we need to. Catch an exception if we don't.
Also, updating the comment about sqlite being crazy :)
This commit is contained in:
parent
3a8d0e145e
commit
e6288a68e1
@ -860,8 +860,8 @@ def revert_username_index(db):
|
|||||||
replace_table_hack(db, user_table, new_user_table)
|
replace_table_hack(db, user_table, new_user_table)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# If the db is not run using SQLite, this process is much simpler...
|
# If the db is not run using SQLite, we don't need to do crazy
|
||||||
# ...as usual ;)
|
# table copying.
|
||||||
|
|
||||||
# Remove whichever of the not-used indexes are in place
|
# Remove whichever of the not-used indexes are in place
|
||||||
if u'ix_core__users_uploader' in indexes:
|
if u'ix_core__users_uploader' in indexes:
|
||||||
@ -872,9 +872,13 @@ def revert_username_index(db):
|
|||||||
index.drop()
|
index.drop()
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# Add the unique constraint
|
try:
|
||||||
constraint = UniqueConstraint(
|
# Add the unique constraint
|
||||||
'username', table=user_table)
|
constraint = UniqueConstraint(
|
||||||
constraint.create()
|
'username', table=user_table)
|
||||||
|
constraint.create()
|
||||||
|
except ProgrammingError:
|
||||||
|
# constraint already exists, no need to add
|
||||||
|
pass
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user