Files
TuxDMX-WebUI/backend/alembic/versions/20260722_0003_scene_targets.py
T
thomas 1f110866f5
CI / backend (pull_request) Canceled after 0s
CI / shell (pull_request) Canceled after 0s
CI / frontend (pull_request) Canceled after 0s
CI / arm64-smoke (pull_request) Canceled after 0s
CI / backend (push) Canceled after 0s
CI / shell (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / arm64-smoke (push) Canceled after 0s
Update docs and screenshots
2026-07-25 10:26:29 +02:00

45 lines
1.2 KiB
Python

"""Add persisted scene targets."""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision = "20260722_0003"
down_revision = "20260719_0002"
branch_labels = None
depends_on = None
def upgrade() -> None:
bind = op.get_bind()
inspector = sa.inspect(bind)
tables = set(inspector.get_table_names())
if "scenes" not in tables:
return
columns = {column["name"] for column in inspector.get_columns("scenes")}
if "targets" not in columns:
with op.batch_alter_table("scenes") as batch_op:
batch_op.add_column(
sa.Column(
"targets",
sa.JSON(),
nullable=False,
server_default=sa.text("'[]'"),
)
)
def downgrade() -> None:
bind = op.get_bind()
inspector = sa.inspect(bind)
tables = set(inspector.get_table_names())
if "scenes" not in tables:
return
columns = {column["name"] for column in inspector.get_columns("scenes")}
if "targets" in columns:
with op.batch_alter_table("scenes") as batch_op:
batch_op.drop_column("targets")