From 6a8c83f99becbb6662447babdba7fe14249d39d6 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 5 May 2024 21:58:51 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20add=20the=20new=20passwo?= =?UTF-8?q?rd=20salt/iterations=20columns=20if=20already=20present.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And, similarly, don't remove them if they aren't on the user table. --- ...9530cb_added_password_hashing_parameters_to_.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platypush/migrations/alembic/versions/0876439530cb_added_password_hashing_parameters_to_.py b/platypush/migrations/alembic/versions/0876439530cb_added_password_hashing_parameters_to_.py index 58b168e39d..4d1c7011aa 100644 --- a/platypush/migrations/alembic/versions/0876439530cb_added_password_hashing_parameters_to_.py +++ b/platypush/migrations/alembic/versions/0876439530cb_added_password_hashing_parameters_to_.py @@ -27,8 +27,11 @@ def upgrade() -> None: print('The table `user` does not exist, skipping migration') return - op.add_column('user', sa.Column('password_salt', sa.String(), nullable=True)) - op.add_column('user', sa.Column('hmac_iterations', sa.Integer(), nullable=True)) + if 'password_salt' not in user_table.columns: + op.add_column('user', sa.Column('password_salt', sa.String(), nullable=True)) + + if 'hmac_iterations' not in user_table.columns: + op.add_column('user', sa.Column('hmac_iterations', sa.Integer(), nullable=True)) def downgrade() -> None: @@ -41,5 +44,8 @@ def downgrade() -> None: print('The table `user` does not exist, skipping migration') return - op.drop_column('user', 'password_salt') - op.drop_column('user', 'hmac_iterations') + if 'password_salt' in user_table.columns: + op.drop_column('user', 'password_salt') + + if 'hmac_iterations' in user_table.columns: + op.drop_column('user', 'hmac_iterations')