-- 数据清理配置表
CREATE TABLE IF NOT EXISTS tb_data_cleanup_config (
    id BIGSERIAL PRIMARY KEY,
    table_name VARCHAR(100) NOT NULL UNIQUE,
    retention_days INT NOT NULL,
    enabled SMALLINT NOT NULL DEFAULT 1,
    batch_size INT NOT NULL DEFAULT 10000,
    description TEXT,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_by BIGINT
);

-- 索引
CREATE INDEX idx_data_cleanup_config_enabled ON tb_data_cleanup_config(enabled);

-- 表注释
COMMENT ON TABLE tb_data_cleanup_config IS '数据清理配置表 - 定义各表的数据保留策略';

-- 列注释
COMMENT ON COLUMN tb_data_cleanup_config.table_name IS '表名';
COMMENT ON COLUMN tb_data_cleanup_config.retention_days IS '保留天数';
COMMENT ON COLUMN tb_data_cleanup_config.enabled IS '是否启用：0-禁用，1-启用';
COMMENT ON COLUMN tb_data_cleanup_config.batch_size IS '每批删除条数';
COMMENT ON COLUMN tb_data_cleanup_config.description IS '配置说明';
COMMENT ON COLUMN tb_data_cleanup_config.created_at IS '创建时间';
COMMENT ON COLUMN tb_data_cleanup_config.updated_at IS '更新时间';
COMMENT ON COLUMN tb_data_cleanup_config.updated_by IS '更新人ID';
