1
0

1b6d7dc5600a_versioning_passwords.py 867 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """versioning_passwords
  2. Revision ID: 1b6d7dc5600a
  3. Revises: 3b441ef4e928
  4. Create Date: 2016-01-13 07:57:23.465676
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '1b6d7dc5600a'
  8. down_revision = '3b441ef4e928'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. import sqlalchemy.orm
  12. try:
  13. from pagure.lib import model
  14. except ImportError:
  15. import sys
  16. sys.path.insert(0, '.')
  17. from pagure.lib import model
  18. def upgrade():
  19. engine = op.get_bind()
  20. Session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker())
  21. Session.configure(bind=engine)
  22. session = Session()
  23. for user in session.query(model.User).filter(
  24. model.User.password != None).all():
  25. user.password = '$1$%s' % user.password
  26. session.add(user)
  27. session.commit()
  28. def downgrade():
  29. raise ValueError("Password can not be downgraded")