Fix unique constraints for id column (#1583)
* Fix unique constraints for id column * Update version in pyproject.toml
This commit is contained in:
parent
b43e4de38f
commit
feb29ddbb9
3 changed files with 505 additions and 481 deletions
|
|
@ -26,20 +26,14 @@ def upgrade() -> None:
|
|||
flow_constraints = inspector.get_unique_constraints("flow")
|
||||
user_constraints = inspector.get_unique_constraints("user")
|
||||
try:
|
||||
if not any(
|
||||
constraint["name"] == "uq_apikey_id" for constraint in api_key_constraints
|
||||
):
|
||||
if not any(constraint['column_names'] == ['id'] for constraint in api_key_constraints):
|
||||
with op.batch_alter_table("apikey", schema=None) as batch_op:
|
||||
|
||||
batch_op.create_unique_constraint("uq_apikey_id", ["id"])
|
||||
if not any(
|
||||
constraint["name"] == "uq_flow_id" for constraint in flow_constraints
|
||||
):
|
||||
if not any(constraint["column_names"] == ["id"] for constraint in flow_constraints):
|
||||
with op.batch_alter_table("flow", schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint("uq_flow_id", ["id"])
|
||||
if not any(
|
||||
constraint["name"] == "uq_user_id" for constraint in user_constraints
|
||||
):
|
||||
if not any(constraint["column_names"] == ["id"] for constraint in user_constraints):
|
||||
with op.batch_alter_table("user", schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint("uq_user_id", ["id"])
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue