-- M5 角色与场景资产

CREATE TABLE characters (
    id                   BIGINT          NOT NULL PRIMARY KEY,
    project_id           BIGINT          NOT NULL,
    tenant_id            BIGINT          NOT NULL,
    name                 VARCHAR(128)    NOT NULL,
    role_type            VARCHAR(32),
    gender               VARCHAR(16),
    age                  VARCHAR(32),
    personality          TEXT,
    background           TEXT,
    costume              TEXT,
    visual_hint          TEXT,
    image_prompt         TEXT,
    image_url            VARCHAR(1024),
    image_tos_key        VARCHAR(512),
    status               VARCHAR(32)     NOT NULL DEFAULT 'draft',
    created_at           DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    updated_at           DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
    INDEX idx_project (project_id),
    INDEX idx_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE scenes (
    id                   BIGINT          NOT NULL PRIMARY KEY,
    project_id           BIGINT          NOT NULL,
    tenant_id            BIGINT          NOT NULL,
    name                 VARCHAR(128)    NOT NULL,
    scene_type           VARCHAR(32),
    description          TEXT,
    image_prompt         TEXT,
    image_url            VARCHAR(1024),
    image_tos_key        VARCHAR(512),
    status               VARCHAR(32)     NOT NULL DEFAULT 'draft',
    created_at           DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    updated_at           DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
    INDEX idx_project (project_id),
    INDEX idx_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
