fix issue with removing account if it created some API Key

This commit is contained in:
ghostersk
2025-05-27 11:21:58 +01:00
parent cb9b50bd9b
commit 510501ce7e
12 changed files with 236 additions and 10 deletions
@@ -0,0 +1,34 @@
"""Remove user_id from ApiKey
Revision ID: 4b74b8a01154
Revises:
Create Date: 2025-05-27 11:13:02.044857
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4b74b8a01154'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# SQLite doesn't enforce foreign key constraints by default
# So we can just drop the column
with op.batch_alter_table('app_auth_api_keys', schema=None) as batch_op:
batch_op.drop_column('user_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('app_auth_api_keys', schema=None) as batch_op:
batch_op.add_column(sa.Column('user_id', sa.INTEGER(), nullable=False))
batch_op.create_foreign_key('fk_api_keys_user_id', 'app_auth_users', ['user_id'], ['id'])
# ### end Alembic commands ###