Files
ai_academy/migrations/versioned/000139_training_templates.up.sql
T

23 lines
1.1 KiB
SQL

-- Migration: 000139_training_templates
-- Description: 配置中心「导入模板管理」:tr_templates 存租户自定义的 Excel 导入模板
-- (年度教育培训收集模板/题库导入版试题模板,约几十 KB 级,存 bytea);
-- 未上传自定义版本时,下载接口回退到二进制内置默认(internal/assets/trainingtemplates)。
CREATE TABLE IF NOT EXISTS tr_templates (
id VARCHAR(36) PRIMARY KEY DEFAULT uuid_generate_v4(),
tenant_id BIGINT NOT NULL,
template_key VARCHAR(64) NOT NULL,
file_name VARCHAR(255) NOT NULL DEFAULT '',
file_size BIGINT NOT NULL DEFAULT 0,
file_content BYTEA NOT NULL,
updated_by VARCHAR(36) NOT NULL DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE
);
CREATE UNIQUE INDEX IF NOT EXISTS uq_tr_templates_key
ON tr_templates(tenant_id, template_key) WHERE deleted_at IS NULL;
COMMENT ON TABLE tr_templates IS '企业培训 Excel 导入模板(配置中心管理);template_key: demand_collection/question_bank';