"""event_db Revision ID: c1178d5fa549 Revises: f7dd3165f238 Create Date: 2025-06-08 12:29:28.366231 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import mysql # revision identifiers, used by Alembic. revision: str = 'c1178d5fa549' down_revision: Union[str, None] = 'f7dd3165f238' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: """Upgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.create_table('events', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('client_uuid', sa.String(length=36), nullable=False), sa.Column('title', sa.String(length=100), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('start', sa.TIMESTAMP(timezone=True), nullable=False), sa.Column('end', sa.TIMESTAMP(timezone=True), nullable=False), sa.Column('event_type', sa.Enum('presentation', 'website', 'video', 'message', 'other', 'webuntis', name='eventtype'), nullable=False), sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True), sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True), sa.Column('created_by', sa.Integer(), nullable=False), sa.Column('updated_by', sa.Integer(), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=False), sa.ForeignKeyConstraint(['client_uuid'], ['clients.uuid'], ), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.ForeignKeyConstraint(['updated_by'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_events_client_uuid'), 'events', ['client_uuid'], unique=False) op.create_index(op.f('ix_events_end'), 'events', ['end'], unique=False) op.create_index(op.f('ix_events_start'), 'events', ['start'], unique=False) op.create_table('event_media', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('event_id', sa.Integer(), nullable=False), sa.Column('media_type', sa.Enum('presentation', 'website', 'video', 'message', 'other', 'webuntis', name='eventtype'), nullable=False), sa.Column('url', sa.String(length=255), nullable=False), sa.Column('order', sa.Integer(), nullable=True), sa.Column('autoplay', sa.Boolean(), nullable=True), sa.Column('loop', sa.Boolean(), nullable=True), sa.Column('volume', sa.Float(), nullable=True), sa.ForeignKeyConstraint(['event_id'], ['events.id'], ), sa.PrimaryKeyConstraint('id') ) op.add_column('clients', sa.Column('is_active', sa.Boolean(), nullable=False)) op.create_index(op.f('ix_clients_hardware_hash'), 'clients', ['hardware_hash'], unique=False) op.create_index(op.f('ix_clients_ip_address'), 'clients', ['ip_address'], unique=False) op.add_column('users', sa.Column('is_active', sa.Boolean(), nullable=False)) op.alter_column('users', 'password_hash', existing_type=mysql.VARCHAR(length=60), type_=sa.String(length=128), existing_nullable=False) op.drop_index(op.f('username'), table_name='users') op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True) # ### end Alembic commands ### def downgrade() -> None: """Downgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_users_username'), table_name='users') op.create_index(op.f('username'), 'users', ['username'], unique=True) op.alter_column('users', 'password_hash', existing_type=sa.String(length=128), type_=mysql.VARCHAR(length=60), existing_nullable=False) op.drop_column('users', 'is_active') op.drop_index(op.f('ix_clients_ip_address'), table_name='clients') op.drop_index(op.f('ix_clients_hardware_hash'), table_name='clients') op.drop_column('clients', 'is_active') op.drop_table('event_media') op.drop_index(op.f('ix_events_start'), table_name='events') op.drop_index(op.f('ix_events_end'), table_name='events') op.drop_index(op.f('ix_events_client_uuid'), table_name='events') op.drop_table('events') # ### end Alembic commands ###