44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
# #region Alembic.ScenarioWorkingDrafts [C:2] [TYPE Module] [SEMANTICS alembic,scenario,editor,draft,persistence]
|
|
# @ingroup Alembic
|
|
# @BRIEF Add 043 server-owned working drafts table.
|
|
# @LAYER Database
|
|
"""add server-owned scenario working drafts (043 editor)"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "w2x3y4z5a6"
|
|
down_revision: str | Sequence[str] | None = "v1w2x3y4z5a6"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"scenario_working_drafts",
|
|
sa.Column("draft_id", sa.String(length=36), nullable=False),
|
|
sa.Column("scenario_id", sa.String(length=36), nullable=False),
|
|
sa.Column("base_revision_id", sa.String(length=36), nullable=False),
|
|
sa.Column("operations", sa.JSON(), nullable=False),
|
|
sa.Column("applied_graph", sa.JSON(), nullable=False),
|
|
sa.Column("digest", sa.String(length=64), nullable=False),
|
|
sa.Column("created_by", sa.String(length=128), nullable=False),
|
|
sa.Column("status", sa.String(length=24), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(["scenario_id"], ["scenario_registry_entries.scenario_id"], ondelete="CASCADE"),
|
|
sa.PrimaryKeyConstraint("draft_id"),
|
|
)
|
|
op.create_index("ix_scenario_working_drafts_scenario", "scenario_working_drafts", ["scenario_id"])
|
|
op.create_index("ix_scenario_working_drafts_base_revision", "scenario_working_drafts", ["base_revision_id"])
|
|
op.create_index("ix_scenario_working_drafts_status", "scenario_working_drafts", ["status"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_scenario_working_drafts_status", table_name="scenario_working_drafts")
|
|
op.drop_index("ix_scenario_working_drafts_base_revision", table_name="scenario_working_drafts")
|
|
op.drop_index("ix_scenario_working_drafts_scenario", table_name="scenario_working_drafts")
|
|
op.drop_table("scenario_working_drafts")
|
|
# #endregion Alembic.ScenarioWorkingDrafts
|