"""init schema

Revision ID: 3e46d0f29340
Revises: 
Create Date: 2026-06-13 18:54:35.709820

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel  # SQLModel AutoString 등 컬럼 타입 참조


# revision identifiers, used by Alembic.
revision: str = '3e46d0f29340'
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('approval',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('icon', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('risk', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('time', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('detail', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('cta', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('alt', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('undo_label', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('briefing',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('today', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('weather_temp', sa.Integer(), nullable=False),
    sa.Column('weather_cond', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('weather_icon', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('commute', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('sleep', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('note', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('saved_today', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('today_routed', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('event',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('time', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tag', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('dur', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('soon', sa.Boolean(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('folder',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('icon', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=False),
    sa.Column('is_system', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('goal',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('pct', sa.Integer(), nullable=False),
    sa.Column('sub', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('person',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('initial', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('color', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('is_me', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('project',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('folder_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('parent_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=False),
    sa.Column('pinned', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['folder_id'], ['folder.id'], ),
    sa.ForeignKeyConstraint(['parent_id'], ['project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('task',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('project_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('parent_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('status', sa.Enum('todo', 'doing', 'waiting', 'review', 'done', name='taskstatus'), nullable=False),
    sa.Column('assignee_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('due', sa.Date(), nullable=True),
    sa.Column('prio', sa.Enum('high', 'normal', 'low', name='prio'), nullable=False),
    sa.Column('notes', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('est', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('delegated', sa.Boolean(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['assignee_id'], ['person.id'], ),
    sa.ForeignKeyConstraint(['parent_id'], ['task.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('inbox_item',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('kind', sa.Enum('text', 'voice', 'image', name='inboxkind'), nullable=False),
    sa.Column('raw', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('status', sa.Enum('new', 'classified', 'confirmed', 'dismissed', name='inboxstatus'), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('materialized_task_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.ForeignKeyConstraint(['materialized_task_id'], ['task.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('task_comment',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('task_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('person_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('text', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['person.id'], ),
    sa.ForeignKeyConstraint(['task_id'], ['task.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('inbox_classification',
    sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('inbox_item_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('type', sa.Enum('task', 'event', 'idea', name='clstype'), nullable=False),
    sa.Column('sphere', sa.Enum('work', 'life', name='sphere'), nullable=False),
    sa.Column('project_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('proj_label', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('due_text', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('when_text', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('extra', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('reason', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('confidence', sa.Float(), nullable=False),
    sa.Column('model', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['inbox_item_id'], ['inbox_item.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('inbox_classification')
    op.drop_table('task_comment')
    op.drop_table('inbox_item')
    op.drop_table('task')
    op.drop_table('project')
    op.drop_table('person')
    op.drop_table('goal')
    op.drop_table('folder')
    op.drop_table('event')
    op.drop_table('briefing')
    op.drop_table('approval')
    # ### end Alembic commands ###
