Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
984f8dce
Commit
984f8dce
authored
May 15, 2013
by
Christos Stavrakakis
Browse files
cyclades: fix db migration
Migration 0066 should not run on a fresh installation.
parent
e8bc8a17
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/db/migrations/0066_add_iv.py
View file @
984f8dce
...
...
@@ -123,19 +123,22 @@ class Migration(DataMigration):
def
forwards
(
self
,
orm
):
"Write your forwards methods here."
for
backend
in
orm
.
Backend
.
objects
.
all
():
old_pass
=
decrypt_db_charfield_old
(
backend
.
password_hash
)
new_hash
=
encrypt_db_charfield
(
old_pass
)
# Bypass save method!
orm
.
Backend
.
objects
.
filter
(
id
=
backend
.
id
).
update
(
password_hash
=
new_hash
)
old_hash
=
backend
.
password_hash
if
len
(
old_hash
.
split
(
":"
))
==
2
:
old_pass
=
decrypt_db_charfield_old
(
old_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
):
"Write your backwards methods here."
for
backend
in
orm
.
Backend
.
objects
.
all
():
old_pass
=
decrypt_db_charfield
(
backend
.
password_hash
)
new_hash
=
encrypt_db_charfield_old
(
old_pass
)
orm
.
Backend
.
objects
.
filter
(
id
=
backend
.
id
).
update
(
password_hash
=
new_hash
)
try
:
for
backend
in
orm
.
Backend
.
objects
.
all
():
old_pass
=
decrypt_db_charfield
(
backend
.
password_hash
)
new_hash
=
encrypt_db_charfield_old
(
old_pass
)
orm
.
Backend
.
objects
.
filter
(
id
=
backend
.
id
).
update
(
password_hash
=
new_hash
)
except
:
pass
models
=
{
'db.backend'
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment