diff --git a/invenio_accounts/alembic/999dcbd19ace_users_versioning.py b/invenio_accounts/alembic/999dcbd19ace_users_versioning.py index e3070821..a00772d3 100644 --- a/invenio_accounts/alembic/999dcbd19ace_users_versioning.py +++ b/invenio_accounts/alembic/999dcbd19ace_users_versioning.py @@ -34,10 +34,14 @@ def upgrade(): # populate the columns of existing rows op.execute( - text("UPDATE accounts_role SET created = CURRENT_TIMESTAMP, updated = CURRENT_TIMESTAMP, version_id = 1;") + text( + "UPDATE accounts_role SET created = CURRENT_TIMESTAMP, updated = CURRENT_TIMESTAMP, version_id = 1;" + ) ) # noqa op.execute( - text("UPDATE accounts_user SET created = CURRENT_TIMESTAMP, updated = CURRENT_TIMESTAMP, version_id = 1;") + text( + "UPDATE accounts_user SET created = CURRENT_TIMESTAMP, updated = CURRENT_TIMESTAMP, version_id = 1;" + ) ) # noqa # make the columns not nullable diff --git a/invenio_accounts/alembic/dfbdf43a3e96_separate_login_info.py b/invenio_accounts/alembic/dfbdf43a3e96_separate_login_info.py index 24974d77..6c56580f 100644 --- a/invenio_accounts/alembic/dfbdf43a3e96_separate_login_info.py +++ b/invenio_accounts/alembic/dfbdf43a3e96_separate_login_info.py @@ -43,11 +43,11 @@ def upgrade(): # move information from the user table into the new table op.execute( - text( - "INSERT INTO accounts_user_login_information " - "(user_id, current_login_at, current_login_ip, last_login_at, last_login_ip, login_count) " # noqa - "SELECT id, current_login_at, current_login_ip, last_login_at, last_login_ip, login_count " # noqa - "FROM accounts_user;" + text( + "INSERT INTO accounts_user_login_information " + "(user_id, current_login_at, current_login_ip, last_login_at, last_login_ip, login_count) " # noqa + "SELECT id, current_login_at, current_login_ip, last_login_at, last_login_ip, login_count " # noqa + "FROM accounts_user;" ) ) @@ -87,16 +87,18 @@ def downgrade(): # (at least with postgres) dialect_name = op._proxy.migration_context.dialect.name if dialect_name == "postgresql": - op.execute(text( - "UPDATE accounts_user SET " - " current_login_at = li.current_login_at, " - " current_login_ip = li.current_login_ip, " - " last_login_at = li.last_login_at, " - " last_login_ip = li.last_login_ip, " - " login_count = li.login_count " - "FROM accounts_user_login_information AS li " - "WHERE accounts_user.id = li.user_id;" - )) + op.execute( + text( + "UPDATE accounts_user SET " + " current_login_at = li.current_login_at, " + " current_login_ip = li.current_login_ip, " + " last_login_at = li.last_login_at, " + " last_login_ip = li.last_login_ip, " + " login_count = li.login_count " + "FROM accounts_user_login_information AS li " + "WHERE accounts_user.id = li.user_id;" + ) + ) # drop the new table op.drop_table("accounts_user_login_information")