refactor(api): Remove manually specified unique constraint name

Instead, we'll rely on column names while using `on_conflict_do_update`.
pull/19737/head
QuantumGhost 1 year ago
parent 1836b7d4c0
commit ec5cde6827

@ -35,7 +35,7 @@ def upgrade():
sa.Column("value", sa.Text(), nullable=False), sa.Column("value", sa.Text(), nullable=False),
sa.Column("visible", sa.Boolean(), nullable=False), sa.Column("visible", sa.Boolean(), nullable=False),
sa.Column("editable", sa.Boolean(), nullable=False), sa.Column("editable", sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint("id", name="workflow_draft_variables_pkey"), sa.PrimaryKeyConstraint("id", name=op.f("workflow_draft_variables_pkey")),
sa.UniqueConstraint("app_id", "node_id", "name", name=op.f("workflow_draft_variables_app_id_key")), sa.UniqueConstraint("app_id", "node_id", "name", name=op.f("workflow_draft_variables_app_id_key")),
) )

@ -815,17 +815,16 @@ def _naive_utc_datetime():
class WorkflowDraftVariable(Base): class WorkflowDraftVariable(Base):
UNIQUE_INDEX_APP_ID_NODE_ID_NAME = "workflow_draft_variables_app_id_key" @staticmethod
def unique_columns() -> list[str]:
__tablename__ = "workflow_draft_variables" return [
__table_args__ = (
UniqueConstraint(
"app_id", "app_id",
"node_id", "node_id",
"name", "name",
name=UNIQUE_INDEX_APP_ID_NODE_ID_NAME, ]
),
) __tablename__ = "workflow_draft_variables"
__table_args__ = (UniqueConstraint(*unique_columns()),)
# id is the unique identifier of a draft variable. # id is the unique identifier of a draft variable.
id: Mapped[str] = mapped_column(StringUUID, primary_key=True, server_default=db.text("uuid_generate_v4()")) id: Mapped[str] = mapped_column(StringUUID, primary_key=True, server_default=db.text("uuid_generate_v4()"))

Loading…
Cancel
Save