-- 流模板系统 CREATE TABLE IF NOT EXISTS flow_templates ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name VARCHAR(200) NOT NULL, description TEXT, category VARCHAR(50), definition_json JSONB NOT NULL DEFAULT '{}', icon VARCHAR(50), sort_order INTEGER DEFAULT 0, is_builtin BOOLEAN DEFAULT false, usage_count INTEGER DEFAULT 0, created_by UUID REFERENCES users(id), created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() ); CREATE INDEX IF NOT EXISTS idx_flow_templates_category ON flow_templates(category); CREATE INDEX IF NOT EXISTS idx_flow_templates_sort ON flow_templates(sort_order);