"""Initial schema

Revision ID: 72f609dd9e66
Revises: 
Create Date: 2026-01-08 09:52:59.473436

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel


# revision identifiers, used by Alembic.
revision: str = '72f609dd9e66'
down_revision: Union[str, Sequence[str], None] = None
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('projects',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('created_at', sa.Float(), nullable=False),
    sa.Column('updated_at', sa.Float(), nullable=False),
    sa.Column('resolution', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('ratio', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('style_preset', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('style_params', sa.JSON(), nullable=True),
    sa.Column('chapters', sa.JSON(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tasks',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('created_at', sa.Float(), nullable=False),
    sa.Column('updated_at', sa.Float(), nullable=False),
    sa.Column('model', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('params', sa.JSON(), nullable=True),
    sa.Column('provider_task_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('result', sa.JSON(), nullable=True),
    sa.Column('error', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('assets',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('project_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('desc', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tags', sa.JSON(), nullable=True),
    sa.Column('image_url', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('image_urls', sa.JSON(), nullable=True),
    sa.Column('video_urls', sa.JSON(), nullable=True),
    sa.Column('extra_data', sa.JSON(), nullable=True),
    sa.Column('generations', sa.JSON(), nullable=True),
    sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_assets_project_id'), 'assets', ['project_id'], unique=False)
    op.create_table('episodes',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('project_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('order_index', sa.Integer(), nullable=False),
    sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('desc', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('content', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_episodes_project_id'), 'episodes', ['project_id'], unique=False)
    op.create_table('storyboards',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('project_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('episode_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('order_index', sa.Integer(), nullable=False),
    sa.Column('shot', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('desc', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('duration', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('scene_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('character_ids', sa.JSON(), nullable=True),
    sa.Column('prop_ids', sa.JSON(), nullable=True),
    sa.Column('voiceover', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('audio_desc', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('audio_url', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('camera_movement', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('transition', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('visual_anchor', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('visual_dynamics', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('director_note', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('image_prompt', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('video_script', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('image_urls', sa.JSON(), nullable=True),
    sa.Column('video_urls', sa.JSON(), nullable=True),
    sa.Column('generations', sa.JSON(), nullable=True),
    sa.ForeignKeyConstraint(['episode_id'], ['episodes.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_storyboards_episode_id'), 'storyboards', ['episode_id'], unique=False)
    op.create_index(op.f('ix_storyboards_project_id'), 'storyboards', ['project_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_storyboards_project_id'), table_name='storyboards')
    op.drop_index(op.f('ix_storyboards_episode_id'), table_name='storyboards')
    op.drop_table('storyboards')
    op.drop_index(op.f('ix_episodes_project_id'), table_name='episodes')
    op.drop_table('episodes')
    op.drop_index(op.f('ix_assets_project_id'), table_name='assets')
    op.drop_table('assets')
    op.drop_table('tasks')
    op.drop_table('projects')
    # ### end Alembic commands ###
