59 lines
2.8 KiB
Python
59 lines
2.8 KiB
Python
"""editable campaign versions
|
|
|
|
Revision ID: 1f8d4c2a0b7e
|
|
Revises: b57c5b216bce
|
|
Create Date: 2026-06-08 08:00:00.000000
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = "1f8d4c2a0b7e"
|
|
down_revision = "b57c5b216bce"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
with op.batch_alter_table("campaign_versions") as batch_op:
|
|
batch_op.add_column(sa.Column("source_base_path", sa.String(length=1000), nullable=True))
|
|
batch_op.add_column(sa.Column("workflow_state", sa.String(length=50), nullable=False, server_default="editing"))
|
|
batch_op.add_column(sa.Column("current_flow", sa.String(length=50), nullable=False, server_default="manual"))
|
|
batch_op.add_column(sa.Column("current_step", sa.String(length=100), nullable=True))
|
|
batch_op.add_column(sa.Column("is_complete", sa.Boolean(), nullable=False, server_default=sa.false()))
|
|
batch_op.add_column(sa.Column("editor_state", sa.JSON(), nullable=False, server_default=sa.text("'{}'")))
|
|
batch_op.add_column(sa.Column("autosaved_at", sa.DateTime(timezone=True), nullable=True))
|
|
batch_op.add_column(sa.Column("published_at", sa.DateTime(timezone=True), nullable=True))
|
|
batch_op.add_column(sa.Column("locked_at", sa.DateTime(timezone=True), nullable=True))
|
|
batch_op.add_column(sa.Column("locked_by_user_id", sa.String(length=36), nullable=True))
|
|
batch_op.create_foreign_key(
|
|
op.f("fk_campaign_versions_locked_by_user_id_users"),
|
|
"users",
|
|
["locked_by_user_id"],
|
|
["id"],
|
|
ondelete="SET NULL",
|
|
)
|
|
batch_op.create_index(op.f("ix_campaign_versions_workflow_state"), ["workflow_state"], unique=False)
|
|
batch_op.create_index(op.f("ix_campaign_versions_current_flow"), ["current_flow"], unique=False)
|
|
batch_op.create_index(op.f("ix_campaign_versions_locked_by_user_id"), ["locked_by_user_id"], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table("campaign_versions") as batch_op:
|
|
batch_op.drop_index(op.f("ix_campaign_versions_locked_by_user_id"))
|
|
batch_op.drop_index(op.f("ix_campaign_versions_current_flow"))
|
|
batch_op.drop_index(op.f("ix_campaign_versions_workflow_state"))
|
|
batch_op.drop_constraint(op.f("fk_campaign_versions_locked_by_user_id_users"), type_="foreignkey")
|
|
batch_op.drop_column("locked_by_user_id")
|
|
batch_op.drop_column("locked_at")
|
|
batch_op.drop_column("published_at")
|
|
batch_op.drop_column("autosaved_at")
|
|
batch_op.drop_column("editor_state")
|
|
batch_op.drop_column("is_complete")
|
|
batch_op.drop_column("current_step")
|
|
batch_op.drop_column("current_flow")
|
|
batch_op.drop_column("workflow_state")
|
|
batch_op.drop_column("source_base_path")
|