From faaaf00f7f1051585316190e0a5e2738e121ecbd Mon Sep 17 00:00:00 2001 From: imeepos Date: Thu, 25 Sep 2025 22:31:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0workflow=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=88=B0n8n=5Ftemplates=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在N8nTemplateEntity中添加workflow字段 - 创建migration添加workflow列到数据库 - 更新package.json的migration脚本配置 --- package.json | 2 +- src/entities/n8n-template.entity.ts | 3 ++ ...1756990000000-AddWorkflowToN8nTemplates.ts | 29 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/migrations/1756990000000-AddWorkflowToN8nTemplates.ts diff --git a/package.json b/package.json index 3a0be7c..e8eb874 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "typecheck": "tsc --noEmit", "typeorm": "typeorm-ts-node-commonjs", "migration:generate": "npm run typeorm -- migration:generate", - "migration:run": "npm run typeorm -- migration:run", + "migration:run": "npm run typeorm -- migration:run -d data-source.ts", "migration:revert": "npm run typeorm -- migration:revert", "schema:sync": "npm run typeorm -- schema:sync", "schema:drop": "npm run typeorm -- schema:drop", diff --git a/src/entities/n8n-template.entity.ts b/src/entities/n8n-template.entity.ts index abec290..8d92107 100644 --- a/src/entities/n8n-template.entity.ts +++ b/src/entities/n8n-template.entity.ts @@ -32,6 +32,9 @@ export class N8nTemplateEntity { @PrimaryGeneratedColumn('increment', { type: 'bigint' }) id: number; + @Column({ length: 200, comment: '对应n8n 的workflow', default: `` }) + workflow: string; + /** 模板代码 - 模板的唯一标识码,用于API调用和模板引用 */ @Column({ unique: true, length: 100, comment: '模板唯一标识码' }) code: string; diff --git a/src/migrations/1756990000000-AddWorkflowToN8nTemplates.ts b/src/migrations/1756990000000-AddWorkflowToN8nTemplates.ts new file mode 100644 index 0000000..d2151b7 --- /dev/null +++ b/src/migrations/1756990000000-AddWorkflowToN8nTemplates.ts @@ -0,0 +1,29 @@ +import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; + +export class AddWorkflowToN8nTemplates1756990000000 + implements MigrationInterface +{ + name = 'AddWorkflowToN8nTemplates1756990000000'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn( + 'n8n_templates', + new TableColumn({ + name: 'workflow', + type: 'varchar', + length: '200', + default: "''", + isNullable: false, + comment: '对应n8n 的workflow', + }), + ); + + console.log('✅ Added workflow column to n8n_templates table'); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn('n8n_templates', 'workflow'); + + console.log('✅ Dropped workflow column from n8n_templates table'); + } +} \ No newline at end of file