Commit 984f8dce authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: fix db migration

Migration 0066 should not run on a fresh installation.
parent e8bc8a17
...@@ -123,19 +123,22 @@ class Migration(DataMigration): ...@@ -123,19 +123,22 @@ class Migration(DataMigration):
def forwards(self, orm): def forwards(self, orm):
"Write your forwards methods here." "Write your forwards methods here."
for backend in orm.Backend.objects.all(): for backend in orm.Backend.objects.all():
old_pass = decrypt_db_charfield_old(backend.password_hash) old_hash = backend.password_hash
new_hash = encrypt_db_charfield(old_pass) if len(old_hash.split(":")) == 2:
# Bypass save method! old_pass = decrypt_db_charfield_old(old_hash)
orm.Backend.objects.filter(id=backend.id).update(password_hash=new_hash) new_hash = encrypt_db_charfield(old_pass)
# Bypass save method!
orm.Backend.objects.filter(id=backend.id).update(password_hash=new_hash)
def backwards(self, orm): def backwards(self, orm):
"Write your backwards methods here." "Write your backwards methods here."
for backend in orm.Backend.objects.all(): try:
old_pass = decrypt_db_charfield(backend.password_hash) for backend in orm.Backend.objects.all():
new_hash = encrypt_db_charfield_old(old_pass) old_pass = decrypt_db_charfield(backend.password_hash)
orm.Backend.objects.filter(id=backend.id).update(password_hash=new_hash) new_hash = encrypt_db_charfield_old(old_pass)
orm.Backend.objects.filter(id=backend.id).update(password_hash=new_hash)
except:
pass
models = { models = {
'db.backend': { 'db.backend': {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment