🐛 Don't add the new password salt/iterations columns if already present.

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 untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -27,7 +27,10 @@ def upgrade() -> None:
print('The table `user` does not exist, skipping migration') print('The table `user` does not exist, skipping migration')
return return
if 'password_salt' not in user_table.columns:
op.add_column('user', sa.Column('password_salt', sa.String(), nullable=True)) 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)) op.add_column('user', sa.Column('hmac_iterations', sa.Integer(), nullable=True))
@ -41,5 +44,8 @@ def downgrade() -> None:
print('The table `user` does not exist, skipping migration') print('The table `user` does not exist, skipping migration')
return return
if 'password_salt' in user_table.columns:
op.drop_column('user', 'password_salt') op.drop_column('user', 'password_salt')
if 'hmac_iterations' in user_table.columns:
op.drop_column('user', 'hmac_iterations') op.drop_column('user', 'hmac_iterations')