Add foreign key constraint to Credential table
This commit is contained in:
parent
ca9b6be8cb
commit
b9a526b72e
1 changed files with 38 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
||||||
|
"""Fix Credential table
|
||||||
|
|
||||||
|
Revision ID: fd531f8868b1
|
||||||
|
Revises: 2ac71eb9c3ae
|
||||||
|
Create Date: 2023-11-24 15:07:37.566516
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = 'fd531f8868b1'
|
||||||
|
down_revision: Union[str, None] = '2ac71eb9c3ae'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
with op.batch_alter_table('credential', schema=None) as batch_op:
|
||||||
|
batch_op.create_foreign_key("fk_credential_user_id", 'user', ['user_id'], ['id'])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
with op.batch_alter_table('credential', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint("fk_credential_user_id", type_='foreignkey')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
Loading…
Add table
Add a link
Reference in a new issue