-- 视频模型参数配置表
CREATE TABLE IF NOT EXISTS aigcspace.video_model_config (
    id SERIAL PRIMARY KEY,
    model_name VARCHAR(100) NOT NULL UNIQUE,
    model_id VARCHAR(100) NOT NULL,
    model_type VARCHAR(50) NOT NULL,
    supported_params JSONB NOT NULL,
    is_active BOOLEAN DEFAULT TRUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_video_model_config_type ON aigcspace.video_model_config(model_type);
CREATE INDEX IF NOT EXISTS idx_video_model_config_active ON aigcspace.video_model_config(is_active);

COMMENT ON TABLE aigcspace.video_model_config IS '视频模型参数配置表';
COMMENT ON COLUMN aigcspace.video_model_config.model_type IS '模型类型：t2v=文生视频，i2v=图生视频，s2v=数字人合成';

-- 初始化模型配置数据
INSERT INTO aigcspace.video_model_config (model_name, model_id, model_type, supported_params) VALUES
('wan2.2-s2v', 'wan2.2-s2v', 's2v', '{
    "resolutions": ["480P", "720P"],
    "max_audio_duration": 20,
    "max_audio_size_mb": 15,
    "audio_formats": ["wav", "mp3"],
    "supports_audio": true
}'::jsonb),
('wan2.2-s2v-detect', 'wan2.2-s2v-detect', 's2v', '{
    "image_formats": ["jpg", "jpeg", "png", "bmp", "webp"],
    "min_size": 400,
    "max_size": 7000
}'::jsonb),
('wan2.6-t2v', 'wan2.6-t2v', 't2v', '{
    "resolutions": ["720P", "1080P"],
    "durations": [5, 10, 15],
    "max_prompt_length": 1500,
    "supports_audio": true,
    "supports_audio_url": true,
    "supports_multi_shot": true,
    "supports_first_frame": false,
    "supports_last_frame": false,
    "aspect_ratios": {
        "720P": ["1280*720", "720*1280", "960*960"],
        "1080P": ["1920*1080", "1080*1920", "1440*1440"]
    }
}'::jsonb),
('wan2.6-i2v', 'wan2.6-i2v', 'i2v', '{
    "resolutions": ["720P", "1080P"],
    "durations": [5, 10, 15],
    "max_prompt_length": 1500,
    "supports_audio": true,
    "supports_audio_url": true,
    "supports_multi_shot": false,
    "supports_first_frame": true,
    "supports_last_frame": true,
    "aspect_ratios": {
        "720P": ["1280*720", "720*1280", "960*960"],
        "1080P": ["1920*1080", "1080*1920", "1440*1440"]
    }
}'::jsonb)
ON CONFLICT (model_name) DO NOTHING;
