-- 迁移文件: 004_create_model_price_table.sql
-- 描述: 创建模型价格信息表

-- ============================================
-- 正向迁移: 创建 model_price 表
-- ============================================

-- 创建 model_price 表
CREATE TABLE IF NOT EXISTS aigcspace.model_price (
    id SERIAL PRIMARY KEY,
    input_price NUMERIC(10, 4) DEFAULT 0.0001 NOT NULL,
    output_price NUMERIC(10, 4) DEFAULT 0.0001 NOT NULL,
    unit VARCHAR(20) DEFAULT 'tokens' NOT NULL,
    currency VARCHAR(10) DEFAULT 'CNY' NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);

-- 添加表注释
COMMENT ON TABLE aigcspace.model_price IS '模型价格信息表';
COMMENT ON COLUMN aigcspace.model_price.id IS '主键ID';
COMMENT ON COLUMN aigcspace.model_price.input_price IS '输入单价，每token价格';
COMMENT ON COLUMN aigcspace.model_price.output_price IS '输出单价，每token价格';
COMMENT ON COLUMN aigcspace.model_price.unit IS '计价单位，默认tokens';
COMMENT ON COLUMN aigcspace.model_price.currency IS '货币单位，默认CNY';
COMMENT ON COLUMN aigcspace.model_price.created_at IS '创建时间';
COMMENT ON COLUMN aigcspace.model_price.updated_at IS '更新时间';

-- ============================================
-- 回滚迁移: 删除 model_price 表
-- ============================================
-- DROP TABLE IF EXISTS aigcspace.model_price;
