mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-10 08:05:22 +02:00
66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
"""add workflow definition
|
|
|
|
Revision ID: 58f17b468b3c
|
|
Revises: a2b092ff7282
|
|
Create Date: 2025-06-03 13:08:23.709070
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "58f17b468b3c"
|
|
down_revision: Union[str, None] = "a2b092ff7282"
|
|
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! ###
|
|
op.create_table(
|
|
"workflow_definitions",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("workflow_hash", sa.String(), nullable=False),
|
|
sa.Column("workflow_json", sa.JSON(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_workflow_definitions_id"), "workflow_definitions", ["id"], unique=False
|
|
)
|
|
op.create_index(
|
|
op.f("ix_workflow_definitions_workflow_hash"),
|
|
"workflow_definitions",
|
|
["workflow_hash"],
|
|
unique=True,
|
|
)
|
|
op.add_column(
|
|
"workflow_runs", sa.Column("definition_id", sa.Integer(), nullable=True)
|
|
)
|
|
op.create_foreign_key(
|
|
None, "workflow_runs", "workflow_definitions", ["definition_id"], ["id"]
|
|
)
|
|
op.add_column(
|
|
"workflows", sa.Column("current_definition_id", sa.Integer(), nullable=True)
|
|
)
|
|
op.create_foreign_key(
|
|
None, "workflows", "workflow_definitions", ["current_definition_id"], ["id"]
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_constraint(None, "workflows", type_="foreignkey")
|
|
op.drop_column("workflows", "current_definition_id")
|
|
op.drop_constraint(None, "workflow_runs", type_="foreignkey")
|
|
op.drop_column("workflow_runs", "definition_id")
|
|
op.drop_index(
|
|
op.f("ix_workflow_definitions_workflow_hash"), table_name="workflow_definitions"
|
|
)
|
|
op.drop_index(op.f("ix_workflow_definitions_id"), table_name="workflow_definitions")
|
|
op.drop_table("workflow_definitions")
|
|
# ### end Alembic commands ###
|