🐛 Don't add the new password salt/iterations columns if already present.
continuous-integration/drone/push Build is passing Details

And, similarly, don't remove them if they aren't on the user table.
This commit is contained in:
Fabio Manganiello 2024-05-05 21:58:51 +02:00
parent 901338e228
commit 6a8c83f99b
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 10 additions and 4 deletions

View File

@ -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')