-- 公文模板表 CREATE TABLE IF NOT EXISTS document_templates ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name VARCHAR(100) NOT NULL, doc_type VARCHAR(50) NOT NULL, description TEXT, icon VARCHAR(50), format_standard TEXT NOT NULL DEFAULT '', fields JSONB NOT NULL DEFAULT '[]', prompt_template TEXT NOT NULL DEFAULT '', example_output TEXT, sort_order INT NOT NULL DEFAULT 0, is_active BOOLEAN NOT NULL DEFAULT true, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE INDEX idx_document_templates_doc_type ON document_templates(doc_type); CREATE INDEX idx_document_templates_active ON document_templates(is_active);