"""Signage playlists and slides (plan step 5.4a); media.builtin for pictures shipped with the server. Revision ID: 0029_signage Revises: 0028_display_looks Create Date: 2026-11-17 20:00:00 """ from alembic import op import sqlalchemy as sa from core.timeutil import UTCDateTime revision = '0029_signage' down_revision = '0028_display_looks' branch_labels = None depends_on = None def upgrade() -> None: op.create_table('signage_playlists', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=False), sa.Column('orientation', sa.String(), nullable=False), sa.Column('transition', sa.String(), nullable=False), sa.Column('created_at', UTCDateTime(), nullable=False), sa.Column('updated_at', UTCDateTime(), nullable=False), sa.PrimaryKeyConstraint('id') ) with op.batch_alter_table('signage_playlists', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_signage_playlists_id'), ['id'], unique=False) op.create_table('signage_slides', sa.Column('id', sa.Integer(), nullable=False), sa.Column('playlist_id', sa.Integer(), nullable=False), sa.Column('position', sa.Integer(), nullable=False), sa.Column('kind', sa.String(), nullable=False), sa.Column('name', sa.String(), nullable=True), sa.Column('duration_s', sa.Integer(), nullable=False), sa.Column('transition', sa.String(), nullable=True), sa.Column('video_to_end', sa.Boolean(), nullable=False), sa.Column('enabled', sa.Boolean(), nullable=False), sa.Column('days', sa.JSON(), nullable=True), sa.Column('time_from', sa.String(), nullable=True), sa.Column('time_to', sa.String(), nullable=True), sa.Column('date_from', sa.String(), nullable=True), sa.Column('date_to', sa.String(), nullable=True), sa.Column('content', sa.JSON(), nullable=False), sa.ForeignKeyConstraint(['playlist_id'], ['signage_playlists.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) with op.batch_alter_table('signage_slides', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_signage_slides_id'), ['id'], unique=False) batch_op.create_index(batch_op.f('ix_signage_slides_playlist_id'), ['playlist_id'], unique=False) with op.batch_alter_table('media', schema=None) as batch_op: batch_op.add_column(sa.Column('builtin', sa.Boolean(), server_default='0', nullable=False)) def downgrade() -> None: with op.batch_alter_table('media', schema=None) as batch_op: batch_op.drop_column('builtin') with op.batch_alter_table('signage_slides', schema=None) as batch_op: batch_op.drop_index(batch_op.f('ix_signage_slides_playlist_id')) batch_op.drop_index(batch_op.f('ix_signage_slides_id')) op.drop_table('signage_slides') with op.batch_alter_table('signage_playlists', schema=None) as batch_op: batch_op.drop_index(batch_op.f('ix_signage_playlists_id')) op.drop_table('signage_playlists')