"""Task 3.05: Create voice_clone_profiles table

Revision ID: 019
Revises: 018
Create Date: 2026-07-02

新增 voice_clone_profiles 表，用于存储音色克隆档案。
"""

import sqlalchemy as sa

from alembic import op

revision = "019"
down_revision = "018"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.create_table(
        "voice_clone_profiles",
        sa.Column("id", sa.String(36), primary_key=True),
        sa.Column("user_id", sa.String(36), nullable=False, index=True),
        sa.Column("name", sa.String(100), nullable=False),
        sa.Column("description", sa.Text(), nullable=False, server_default=""),
        sa.Column("source_audio_url", sa.Text(), nullable=False, server_default=""),
        sa.Column("voice_id", sa.String(100), nullable=False, server_default=""),
        sa.Column("voice_model", sa.String(100), nullable=False, server_default=""),
        sa.Column("language", sa.String(20), nullable=False, server_default="zh-CN"),
        sa.Column("gender", sa.String(20), nullable=False, server_default="unknown"),
        sa.Column("status", sa.String(20), nullable=False, server_default="pending", index=True),
        sa.Column("error_message", sa.Text(), nullable=False, server_default=""),
        sa.Column("retry_count", sa.Integer(), nullable=False, server_default="0"),
        sa.Column("max_retries", sa.Integer(), nullable=False, server_default="3"),
        sa.Column("metadata", sa.JSON(), nullable=False, server_default="{}"),
        sa.Column(
            "created_at",
            sa.DateTime(),
            nullable=False,
            server_default=sa.func.now(),
        ),
        sa.Column(
            "updated_at",
            sa.DateTime(),
            nullable=False,
            server_default=sa.func.now(),
        ),
    )


def downgrade() -> None:
    op.drop_table("voice_clone_profiles")
