Skip to content

Commit

Permalink
Add constraint name to migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
tcompa committed Sep 18, 2024
1 parent ba59b55 commit 4fc4066
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
depends_on = None


CONSTRAINT_NAME = "fk_user_oauth_user_settings_id_user_settings"


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
Expand Down Expand Up @@ -46,7 +49,7 @@ def upgrade() -> None:
sa.Column("user_settings_id", sa.Integer(), nullable=True)
)
batch_op.create_foreign_key(
None, "user_settings", ["user_settings_id"], ["id"]
CONSTRAINT_NAME, "user_settings", ["user_settings_id"], ["id"]
)

# ### end Alembic commands ###
Expand All @@ -55,7 +58,7 @@ def upgrade() -> None:
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("user_oauth", schema=None) as batch_op:
batch_op.drop_constraint(None, type_="foreignkey")
batch_op.drop_constraint(CONSTRAINT_NAME, type_="foreignkey")
batch_op.drop_column("user_settings_id")

op.drop_table("user_settings")
Expand Down

0 comments on commit 4fc4066

Please sign in to comment.