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