"""init

Revision ID: cff71e2494b9
Revises: 
Create Date: 2025-11-07 17:08:33.162758

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'cff71e2494b9'
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('experiments',
    sa.Column('uuid', sa.UUID(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('project_id', sa.UUID(), nullable=False),
    sa.Column('meta', sa.JSON(), nullable=True, comment='Additional metadata for the experiment'),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('is_del', sa.Integer(), nullable=True, comment='0 for not deleted, 1 for deleted'),
    sa.PrimaryKeyConstraint('uuid')
    )
    op.create_table('metrics',
    sa.Column('uuid', sa.UUID(), nullable=False),
    sa.Column('key', sa.String(), nullable=False),
    sa.Column('value', sa.Float(), nullable=False),
    sa.Column('project_id', sa.UUID(), nullable=False),
    sa.Column('trial_id', sa.UUID(), nullable=False),
    sa.Column('step', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('uuid')
    )
    op.create_table('models',
    sa.Column('uuid', sa.UUID(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('project_id', sa.UUID(), nullable=False),
    sa.Column('version', sa.String(), nullable=False),
    sa.Column('meta', sa.JSON(), nullable=True, comment='Additional metadata for the model'),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('is_del', sa.Integer(), nullable=True, comment='0 for not deleted, 1 for deleted'),
    sa.PrimaryKeyConstraint('uuid'),
    sa.UniqueConstraint('name')
    )
    op.create_table('projects',
    sa.Column('uuid', sa.UUID(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('is_del', sa.Integer(), nullable=True, comment='0 for not deleted, 1 for deleted'),
    sa.PrimaryKeyConstraint('uuid')
    )
    op.create_table('runs',
    sa.Column('uuid', sa.UUID(), nullable=False),
    sa.Column('project_id', sa.UUID(), nullable=False),
    sa.Column('trial_id', sa.UUID(), nullable=False),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('uuid')
    )
    op.create_table('trials',
    sa.Column('uuid', sa.UUID(), nullable=False),
    sa.Column('project_id', sa.UUID(), nullable=False),
    sa.Column('experiment_id', sa.UUID(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('meta', sa.JSON(), nullable=True, comment='Additional metadata for the trial'),
    sa.Column('duration', sa.Integer(), nullable=True, comment='Duration in seconds'),
    sa.Column('params', sa.JSON(), nullable=True, comment='Parameters for the experiment'),
    sa.Column('status', sa.Enum('PENDING', 'RUNNING', 'FINISHED', 'FAILED', name='trialstatus'), nullable=False, comment='Status of the trial'),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('uuid')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('trials')
    op.drop_table('runs')
    op.drop_table('projects')
    op.drop_table('models')
    op.drop_table('metrics')
    op.drop_table('experiments')
    # ### end Alembic commands ###
