Blame alembic/versions/1b6d7dc5600a_versioning_passwords.py
|
farhaanbukhsh |
fc2582 |
"""versioning_passwords
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
Revision ID: 1b6d7dc5600a
|
|
farhaanbukhsh |
fc2582 |
Revises: 3b441ef4e928
|
|
farhaanbukhsh |
fc2582 |
Create Date: 2016-01-13 07:57:23.465676
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
"""
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
# revision identifiers, used by Alembic.
|
|
farhaanbukhsh |
fc2582 |
revision = '1b6d7dc5600a'
|
|
farhaanbukhsh |
fc2582 |
down_revision = '3b441ef4e928'
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
from alembic import op
|
|
farhaanbukhsh |
fc2582 |
import sqlalchemy as sa
|
|
farhaanbukhsh |
288e6b |
import sqlalchemy.orm
|
|
Pierre-Yves Chibon |
746413 |
|
|
Pierre-Yves Chibon |
746413 |
try:
|
|
Pierre-Yves Chibon |
746413 |
from pagure.lib import model
|
|
Pierre-Yves Chibon |
746413 |
except ImportError:
|
|
Pierre-Yves Chibon |
746413 |
import sys
|
|
Pierre-Yves Chibon |
746413 |
sys.path.insert(0, '.')
|
|
Pierre-Yves Chibon |
746413 |
from pagure.lib import model
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
28d841 |
|
|
farhaanbukhsh |
fc2582 |
def upgrade():
|
|
Pierre-Yves Chibon |
dd4f8a |
engine = op.get_bind()
|
|
Pierre-Yves Chibon |
dd4f8a |
Session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker())
|
|
Pierre-Yves Chibon |
dd4f8a |
Session.configure(bind=engine)
|
|
Pierre-Yves Chibon |
dd4f8a |
session = Session()
|
|
Pierre-Yves Chibon |
dd4f8a |
for user in session.query(model.User).filter(
|
|
Pierre-Yves Chibon |
dd4f8a |
model.User.password != None).all():
|
|
Pierre-Yves Chibon |
dd4f8a |
user.password = '$1$%s' % user.password
|
|
Pierre-Yves Chibon |
dd4f8a |
session.add(user)
|
|
farhaanbukhsh |
fa5c9a |
session.commit()
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
def downgrade():
|
|
farhaanbukhsh |
28d841 |
raise ValueError("Password can not be downgraded")
|