8
n8n 中文网amn8n.com

使用Claude多Agent系统为SQL数据库生成完整数据库模式

高级

这是一个自动化工作流,包含 31 个节点。主要使用 If, Set, Form, Postgres, FormTrigger 等节点。 使用Claude多Agent系统为SQL数据库生成完整数据库模式

前置要求
  • PostgreSQL 数据库连接信息
  • Anthropic API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "id": "6372d515-3314-4ca8-acf4-462fb4e2fbb1",
      "name": "初始化变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -832,
        -3104
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "init_iteration",
              "name": "iteration_count",
              "type": "number",
              "value": 0
            },
            {
              "id": "init_feedback",
              "name": "previous_feedback",
              "type": "string",
              "value": "="
            },
            {
              "id": "form_data",
              "name": "form_data",
              "type": "object",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e102d0ff-e176-49b5-a999-a3ccf2fb7f42",
      "name": "架构师模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -480,
        -2880
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.9,
          "temperature": 0.3
        }
      },
      "credentials": {
        "anthropicApi": {
          "id": "rFsH3A7ko19Tb8xL",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "1648a9d6-a261-45b8-8dc9-516fd62a7a3e",
      "name": "评审员模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -64,
        -2944
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.85,
          "temperature": 0.1
        }
      },
      "credentials": {
        "anthropicApi": {
          "id": "rFsH3A7ko19Tb8xL",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "87d374f8-babb-41f5-ac5c-f45be51df90c",
      "name": "优化器模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        320,
        -2928
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.95,
          "temperature": 0.5
        }
      },
      "credentials": {
        "anthropicApi": {
          "id": "rFsH3A7ko19Tb8xL",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "a5028fd9-b726-413b-86aa-9f3735395bb9",
      "name": "代理1:数据库架构师",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -544,
        -3120
      ],
      "parameters": {
        "text": "=Database Requirements:\n- What they're building: {{ $json.form_data['What are you building?'] }}\n- Database Technology: {{ $json.form_data['Database Technology'] }}\n- Industry: {{ $json.form_data['Industry/Niche'] }}\n- Data to track: {{ $json.form_data['What data do you need to track?'] }}\n- Team size: {{ $json.form_data['Team Size'] }}\n- Expected scale: {{ $json.form_data['Expected Scale'] }}\n- Key workflows: {{ $json.form_data['Key Workflows'] }}\n- Integrations: {{ $json.form_data['Any integrations needed?'] }}\n- Special requirements: {{ $json.form_data['Special Requirements'] }}\n\n{{ $json.previous_feedback ? '⚠️ PREVIOUS DESIGN HAD ISSUES - ITERATION ' + ($json.iteration_count + 1) + '/3:\\n\\nPrevious Feedback:\\n' + $json.previous_feedback + '\\n\\nPlease redesign the schema addressing ALL the concerns mentioned above. Focus especially on CRITICAL and HIGH priority items.\\n\\n' : '' }}\n\nPlease design a complete {{ $json.form_data['Database Technology'] }} database schema for this use case. Output your design as structured JSON.",
        "options": {
          "systemMessage": "=You are a senior {{ $json.form_data['Database Technology'] }} database architect with 15+ years experience.\nYou design production-grade schemas that are scalable, normalized, and follow best practices. You consider performance, indexing, and future growth.\n\nOutput your design as structured JSON with:\n- tables: Array of table objects with:\n  - name: string\n  - columns: Array of {name, type, constraints, description}\n  - primary_key: string or array\n  - indexes: Array of {name, columns, type}\n  - foreign_keys: Array of {column, references_table, references_column}\n- enums: Array of {name, values}\n- extensions: Array of extension names needed\n- relationships: Description of how tables relate\n- reasoning: Explanation for key design decisions\n\nBe thorough and production-ready. Consider the scale and requirements carefully."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "58921f8a-0b6f-460b-8202-69327c364d45",
      "name": "代理2:模式评审员",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -144,
        -3120
      ],
      "parameters": {
        "text": "=Original Requirements:\n{{ JSON.stringify($('Initialize Variables').item.json.form_data, null, 2) }}\n\nProposed Schema from Agent 1:\n{{ $('Agent 1: Database Architect').item.json.output }}\n\nPlease conduct a thorough review of this database schema design. Check for issues in normalization, indexing, data types, constraints, performance, scalability, and security.\n\nOutput structured feedback with severity levels: CRITICAL, HIGH, MEDIUM, LOW",
        "options": {
          "systemMessage": "You are a {{ $('Initialize Variables').item.json.form_data['Database Technology'] }} code reviewer and database optimization expert.\nYour job is to find issues, enforce best practices, and ensure production-readiness.\n\nReview checklist:\n- Normalization (3NF minimum, appropriate denormalization)\n- Indexing strategy (missing indexes? over-indexing?)\n- Data types (appropriate choices for the database type)\n- Constraints (missing NOT NULL? need CHECK constraints?)\n- Performance (N+1 query risks? missing composite indexes?)\n- Scalability (will this work at 10x, 100x scale?)\n- Security (sensitive data? need encryption? row-level security?)\n- Missing common fields (created_at, updated_at, soft deletes)\n- Relationships properly defined\n\nOutput structured feedback in this format:\n\nCRITICAL Issues:\n- [Issue 1]\n- [Issue 2]\n\nHIGH Priority:\n- [Issue 1]\n\nMEDIUM Priority:\n- [Issue 1]\n\nLOW Priority / Suggestions:\n- [Issue 1]\n\nPositive Aspects:\n- [Good thing 1]\n\nBe thorough but fair. If the design is solid, say so."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "4e2a9518-4587-4ffe-a4a0-3f771019f22e",
      "name": "代理3:优化器与评分器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        272,
        -3120
      ],
      "parameters": {
        "text": "=Original Requirements:\n{{ JSON.stringify($('Initialize Variables').item.json.form_data, null, 2) }}\n\nProposed Schema:\n{{ $('Agent 1: Database Architect').item.json.output }}\n\nReview Feedback:\n{{ $('Agent 2: Schema Reviewer').item.json.output }}\n\nPlease:\n1. Apply final polish and optimizations to the schema\n2. Add advanced features (materialized views, helper functions, useful views)\n3. Provide monitoring recommendations\n4. Create a comprehensive score card\n5. Generate implementation guidance\n\nScore each dimension 0-10 with justification. Be honest but constructive.",
        "options": {
          "systemMessage": "You are a {{ $('Initialize Variables').item.json.form_data['Database Technology'] }} performance optimizer and database strategist.\nApply final polish, add advanced features, and score the design holistically.\n\nAdd:\n- Performance optimizations (materialized views, covering indexes, partitioning if needed)\n- Developer experience improvements (useful views, helper functions)\n- Monitoring recommendations (what to track in production)\n- Migration strategy (how to deploy safely)\n- Backup and disaster recovery considerations\n\nCreate a comprehensive score card:\n\n📊 DATABASE ARCHITECTURE SCORE\n\nOverall Grade: [A+, A, A-, B+, B, B-, C+, C, C-, D, F] ([score]/100)\n\nDetailed Scores:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nSchema Design: [X]/10\n[Brief justification]\n\nPerformance: [X]/10\n[Brief justification]\n\nScalability: [X]/10\n[Brief justification]\n\nDeveloper Experience: [X]/10\n[Brief justification]\n\nProduction Readiness: [X]/10\n[Brief justification]\n\nSecurity: [X]/10\n[Brief justification]\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n💪 Key Strengths:\n• [Strength 1]\n• [Strength 2]\n• [Strength 3]\n\n⚠️ Recommended Improvements:\n• [Improvement 1]\n• [Improvement 2]\n\n🚀 Next Steps:\n1. [Step 1]\n2. [Step 2]\n3. [Step 3]\n\nScore fairly but be honest. Grade A/B means production-ready, C means needs work, D/F means major issues."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "0b898ea5-9799-4b59-b26b-0b0521a8e2c6",
      "name": "跟踪迭代",
      "type": "n8n-nodes-base.set",
      "position": [
        608,
        -2896
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "iteration",
              "name": "iteration_count",
              "type": "number",
              "value": "={{ $('Initialize Variables').item.json.iteration_count + 1 }}"
            },
            {
              "id": "feedback",
              "name": "previous_feedback",
              "type": "string",
              "value": "={{ $('Agent 3: Optimizer & Scorer').item.json.output }}"
            },
            {
              "id": "form_data_passthrough",
              "name": "form_data",
              "type": "object",
              "value": "={{ $('Initialize Variables').item.json.form_data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "21ea3c45-a89d-4f45-b044-958be52b13be",
      "name": "SQL生成器模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        1248,
        -2944
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.85,
          "temperature": 0.2
        }
      },
      "credentials": {
        "anthropicApi": {
          "id": "rFsH3A7ko19Tb8xL",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "739b10a8-f533-403f-b71f-9095d982b669",
      "name": "代理4:生成SQL脚本",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1232,
        -3200
      ],
      "parameters": {
        "text": "=Database Technology: {{ $('Initialize Variables').item.json.form_data['Database Technology'] }}\n\nFinal Approved Schema:\n{{ $('Agent 1: Database Architect').item.json.output }}\n\nOptimizations and Enhancements:\n{{ $('Agent 3: Optimizer & Scorer').item.json.output }}\n\nPlease generate a complete, production-ready SQL migration script for {{ $('Initialize Variables').item.json.form_data['Database Technology'] }}.\n\nOutput ONLY the SQL script, no markdown formatting, no additional commentary.",
        "options": {
          "systemMessage": "=You are a {{ $('Initialize Variables').item.json.form_data['Database Technology'] }} SQL script generator.\n\nTake the database schema design and convert it into a complete, production-ready SQL migration script.\n\nYour output must:\n- Start with proper transaction handling (BEGIN; ... COMMIT;)\n- Include all necessary extensions (for PostgreSQL)\n- Create ENUMs before tables that use them\n- Create tables in correct dependency order (referenced tables first)\n- Add all indexes after table creation\n- Add all constraints and triggers\n- Include helpful comments explaining complex parts\n- Be idempotent where possible (IF NOT EXISTS clauses)\n- End with a commented-out rollback script\n\nFormat:\n-- ============================================\n-- Database Migration Script\n-- Generated: [timestamp]\n-- Database: {{ $('Initialize Variables').item.json.form_data['Database Technology'] }}\n-- ============================================\n\nBEGIN;\n\n[Your SQL here]\n\nCOMMIT;\n\n-- ============================================\n-- ROLLBACK SCRIPT (commented out)\n-- ============================================\n-- BEGIN;\n-- [DROP statements in reverse order]\n-- COMMIT;\n\nOutput ONLY the SQL script. No markdown code blocks, no explanations."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "509218a4-3447-49f9-a8bc-b789ba3432ec",
      "name": "成功响应",
      "type": "n8n-nodes-base.set",
      "position": [
        2320,
        -3312
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "execution_status",
              "type": "string",
              "value": "success"
            },
            {
              "id": "message",
              "name": "message",
              "type": "string",
              "value": "✅ Database created successfully!"
            },
            {
              "id": "sql_script",
              "name": "sql_script",
              "type": "string",
              "value": "={{ $('Agent 4: Generate SQL Script').item.json.output }}"
            },
            {
              "id": "schema_design",
              "name": "schema_design",
              "type": "string",
              "value": "={{ $('Agent 1: Database Architect').item.json.output }}"
            },
            {
              "id": "review_feedback",
              "name": "review_feedback",
              "type": "string",
              "value": "={{ $('Agent 2: Schema Reviewer').item.json.output }}"
            },
            {
              "id": "score_card",
              "name": "score_card",
              "type": "string",
              "value": "={{ $('Agent 3: Optimizer & Scorer').item.json.output }}"
            },
            {
              "id": "iterations",
              "name": "iterations_needed",
              "type": "number",
              "value": "={{ $('Initialize Variables').item.json.iteration_count }}"
            },
            {
              "id": "database_tech",
              "name": "database_technology",
              "type": "string",
              "value": "={{ $('Initialize Variables').item.json.form_data['Database Technology'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fa2b059f-7347-4c81-a194-4e7b02e0a033",
      "name": "错误响应",
      "type": "n8n-nodes-base.set",
      "position": [
        2320,
        -3088
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "execution_status",
              "type": "string",
              "value": "failed"
            },
            {
              "id": "message",
              "name": "message",
              "type": "string",
              "value": "⚠️ SQL script generated but execution failed. You can still use the script manually."
            },
            {
              "id": "error",
              "name": "sql_error",
              "type": "string",
              "value": "={{ $('Execute SQL in PostgreSQL').item.json.error }}"
            },
            {
              "id": "sql_script",
              "name": "sql_script",
              "type": "string",
              "value": "={{ $('Agent 4: Generate SQL Script').item.json.output }}"
            },
            {
              "id": "schema_design",
              "name": "schema_design",
              "type": "string",
              "value": "={{ $('Agent 1: Database Architect').item.json.output }}"
            },
            {
              "id": "review_feedback",
              "name": "review_feedback",
              "type": "string",
              "value": "={{ $('Agent 2: Schema Reviewer').item.json.output }}"
            },
            {
              "id": "score_card",
              "name": "score_card",
              "type": "string",
              "value": "={{ $('Agent 3: Optimizer & Scorer').item.json.output }}"
            },
            {
              "id": "iterations",
              "name": "iterations_needed",
              "type": "number",
              "value": "={{ $('Initialize Variables').item.json.iteration_count }}"
            },
            {
              "id": "database_tech",
              "name": "database_technology",
              "type": "string",
              "value": "={{ $('Initialize Variables').item.json.form_data['Database Technology'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0b8ee65f-e057-4e2e-93c4-859797612c93",
      "name": "达到最大迭代次数",
      "type": "n8n-nodes-base.set",
      "position": [
        1024,
        -3024
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "max_iterations_msg",
              "name": "message",
              "type": "string",
              "value": "⚠️ Reached maximum iterations (3). Proceeding with best available design."
            },
            {
              "id": "passthrough_iteration",
              "name": "iteration_count",
              "type": "number",
              "value": "={{ $json.iteration_count }}"
            },
            {
              "id": "passthrough_form",
              "name": "form_data",
              "type": "object",
              "value": "={{ $json.form_data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ccef25b6-60e3-408e-8d2f-dbc9d907bcc4",
      "name": "是A级还是B级?",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        -3168
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fdbb64c0-d9c9-4568-8aec-2e7679ae846f",
              "operator": {
                "type": "string",
                "operation": "regex"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "Overall Grade: [AB][+-]?"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b25d8d4c-46dc-4a65-99a3-3c03a4ba819c",
      "name": "可以重试?",
      "type": "n8n-nodes-base.if",
      "position": [
        832,
        -2848
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fdbb64c0-d9c9-4568-8aec-2e7679ae846f",
              "operator": {
                "type": "number",
                "operation": "lte"
              },
              "leftValue": "={{ $json.iteration_count }}",
              "rightValue": 3
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c8d4da4b-62af-4d22-8bab-ddfca874ed72",
      "name": "表单",
      "type": "n8n-nodes-base.form",
      "position": [
        2608,
        -3184
      ],
      "webhookId": "0ef42fe9-17ab-4887-b49b-e889d2056d87",
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "SQL Creation Finished",
        "completionMessage": "={{ $json }}"
      },
      "typeVersion": 2.3
    },
    {
      "id": "e5fbeabe-a5de-492e-8cbe-6849882db5fc",
      "name": "在PostgreSQL中执行SQL",
      "type": "n8n-nodes-base.postgres",
      "onError": "continueErrorOutput",
      "position": [
        2000,
        -3200
      ],
      "parameters": {
        "query": "{{ $json.output }}",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "pYPv5XduSxmDtomy",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "146b4b49-a91a-4280-8e2e-74f54f40c9ac",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1728,
        -3104
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 256,
        "content": "## 📝 表单输入"
      },
      "typeVersion": 1
    },
    {
      "id": "c707c920-7fda-4fb0-a175-e6ab1aed64f8",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        -3424
      ],
      "parameters": {
        "color": 4,
        "width": 352,
        "height": 240,
        "content": "## 🔧 设置阶段"
      },
      "typeVersion": 1
    },
    {
      "id": "b375bb08-5363-463d-b34a-76e98eff5443",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -3488
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 320,
        "content": "## 🤖 代理1:架构师"
      },
      "typeVersion": 1
    },
    {
      "id": "3d373fbc-87de-42c2-82e1-536bc7550cef",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        -3488
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 320,
        "content": "## 🤖 代理2:评审员"
      },
      "typeVersion": 1
    },
    {
      "id": "28deacd5-06af-4ec2-b77b-823354b9e306",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -3488
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 320,
        "content": "## 🤖 代理3:优化器"
      },
      "typeVersion": 1
    },
    {
      "id": "b71dce06-6436-446f-8d77-b0f5c46e87e1",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        -3536
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 336,
        "content": "## 🔄 质量门"
      },
      "typeVersion": 1
    },
    {
      "id": "2a05b10e-906c-4be7-919e-b22d74ac15cb",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        -2720
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 304,
        "content": "## 🔁 重试循环"
      },
      "typeVersion": 1
    },
    {
      "id": "881ff4d6-e9ad-4d12-8c88-9b742288161f",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        -3568
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 336,
        "content": "## 🤖 代理4:SQL生成器"
      },
      "typeVersion": 1
    },
    {
      "id": "1bb0fab6-680e-4dad-9d94-4563b3752987",
      "name": "## 为什么选择 4o 模型?👆",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        -3696
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 336,
        "content": "## ✅ 执行验证"
      },
      "typeVersion": 1
    },
    {
      "id": "fd648a76-f6c8-460b-92d4-b00493d98d05",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        -3616
      ],
      "parameters": {
        "color": 6,
        "width": 480,
        "height": 480,
        "content": "## 🚀 工作流概述"
      },
      "typeVersion": 1
    },
    {
      "id": "7febe33c-181c-4c01-9900-71c8ff27249c",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        -2992
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 176,
        "content": "## 查询执行"
      },
      "typeVersion": 1
    },
    {
      "id": "d289f031-8814-4478-8993-00d5c09c03f1",
      "name": "表单提交",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1120,
        -3024
      ],
      "webhookId": "7da47f69-23f9-49e0-8de8-3af4adce1db3",
      "parameters": {
        "options": {},
        "formTitle": "AI Database Architect - By Evervise",
        "formFields": {
          "values": [
            {
              "fieldType": "textarea",
              "fieldLabel": "What are you building?",
              "placeholder": "e.g. CRM for real estate agents",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Database Technology",
              "fieldOptions": {
                "values": [
                  {
                    "option": "PostgreSQL"
                  },
                  {
                    "option": "MySQL"
                  },
                  {
                    "option": "MSSQL"
                  },
                  {
                    "option": "MariaDB"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Industry/Niche",
              "placeholder": "e.g. Real Estate, SaaS, E-commerce",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "What data do you need to track?",
              "placeholder": "e.g. contacts, deals, properties, interactions, documents"
            },
            {
              "fieldType": "number",
              "fieldLabel": "Team Size",
              "placeholder": "5"
            },
            {
              "fieldLabel": "Expected Scale",
              "placeholder": "e.g. 1000 records, 100k records, 1M+ records"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Key Workflows",
              "placeholder": "e.g. lead comes in → assign to agent → track showings → close deal → commission calculation"
            },
            {
              "fieldLabel": "Any integrations needed?",
              "placeholder": "email, calendar, WhatsApp, Stripe, etc."
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Special Requirements",
              "placeholder": "multi-language, file uploads, complex relationships, audit logging, etc."
            },
            {
              "fieldType": "email",
              "fieldLabel": "Your Email",
              "placeholder": "your@email.com",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Get a production-grade database schema designed and reviewed by 3 AI experts"
      },
      "typeVersion": 2.3
    },
    {
      "id": "a4f3bc0e-9293-4917-bd55-2b0309f9d31c",
      "name": "如果用户使用Excel",
      "type": "n8n-nodes-base.if",
      "position": [
        1568,
        -3184
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3ba71a4a-01e0-4be3-bf2e-349fe5c6710c",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Form Submission').item.json['Database Technology'].toLowerCase() }}",
              "rightValue": "postgres"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "93879c3e-e2be-44cc-a5ae-050be780ae42",
      "name": "表单结束不执行",
      "type": "n8n-nodes-base.form",
      "position": [
        1888,
        -2736
      ],
      "webhookId": "0ef42fe9-17ab-4887-b49b-e889d2056d87",
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "SQL Creation Finished",
        "completionMessage": "={{ $json }}"
      },
      "typeVersion": 2.3
    }
  ],
  "connections": {
    "Can Retry?": {
      "main": [
        [
          {
            "node": "Agent 1: Database Architect",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Max Iterations Reached",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Response": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reviewer Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 2: Schema Reviewer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Architect Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 1: Database Architect",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Form Submission": {
      "main": [
        [
          {
            "node": "Initialize Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Optimizer Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 3: Optimizer & Scorer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Track Iteration": {
      "main": [
        [
          {
            "node": "Can Retry?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Score A or B?": {
      "main": [
        [
          {
            "node": "Agent 4: Generate SQL Script",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Track Iteration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success Response": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SQL Generator Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 4: Generate SQL Script",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Initialize Variables": {
      "main": [
        [
          {
            "node": "Agent 1: Database Architect",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If User Is Using Excel": {
      "main": [
        [
          {
            "node": "Execute SQL in PostgreSQL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Form End Without Execute",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Max Iterations Reached": {
      "main": [
        [
          {
            "node": "Agent 4: Generate SQL Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 2: Schema Reviewer": {
      "main": [
        [
          {
            "node": "Agent 3: Optimizer & Scorer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute SQL in PostgreSQL": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 1: Database Architect": {
      "main": [
        [
          {
            "node": "Agent 2: Schema Reviewer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 3: Optimizer & Scorer": {
      "main": [
        [
          {
            "node": "Is Score A or B?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 4: Generate SQL Script": {
      "main": [
        [
          {
            "node": "If User Is Using Excel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量31
分类-
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流