From dd4f8a84b85dd20227ff33ca1307dd96ba317692 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 22 2016 16:06:44 +0000 Subject: Rework the way the session is built and the user's password updated With the previous approach it was like the session was never caught/set so the transaction would never end. With this, in staging, the transaction finished fine. --- diff --git a/alembic/versions/1b6d7dc5600a_versioning_passwords.py b/alembic/versions/1b6d7dc5600a_versioning_passwords.py index ff1aced..f1cd105 100644 --- a/alembic/versions/1b6d7dc5600a_versioning_passwords.py +++ b/alembic/versions/1b6d7dc5600a_versioning_passwords.py @@ -17,10 +17,14 @@ from pagure.lib import model def upgrade(): - engine = op.get_bind().engine - session = sa.orm.scoped_session(sa.orm.sessionmaker(bind=engine)) - session.query(model.User).update( - {model.User.password: '$1$' + model.User.password}, synchronize_session=False) + engine = op.get_bind() + Session = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker()) + Session.configure(bind=engine) + session = Session() + for user in session.query(model.User).filter( + model.User.password != None).all(): + user.password = '$1$%s' % user.password + session.add(user) session.commit()