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
|
|
farhaanbukhsh |
288e6b |
from pagure.lib import model
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
28d841 |
|
|
farhaanbukhsh |
fc2582 |
def upgrade():
|
|
farhaanbukhsh |
fa5c9a |
engine = op.get_bind().engine
|
|
farhaanbukhsh |
fa5c9a |
session = sa.orm.scoped_session(sa.orm.sessionmaker(bind=engine))
|
|
farhaanbukhsh |
fa5c9a |
session.query(model.User).update(
|
|
farhaanbukhsh |
fa5c9a |
{model.User.password: '$1$' + model.User.password}, synchronize_session=False)
|
|
farhaanbukhsh |
fa5c9a |
session.commit()
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
|
|
farhaanbukhsh |
fc2582 |
def downgrade():
|
|
farhaanbukhsh |
28d841 |
raise ValueError("Password can not be downgraded")
|