feat: 添加workflow字段到n8n_templates表

- 在N8nTemplateEntity中添加workflow字段
- 创建migration添加workflow列到数据库
- 更新package.json的migration脚本配置
This commit is contained in:
imeepos 2025-09-25 22:31:28 +08:00
parent 73ca6723ad
commit faaaf00f7f
3 changed files with 33 additions and 1 deletions

View File

@ -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",

View File

@ -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;

View File

@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
export class AddWorkflowToN8nTemplates1756990000000
implements MigrationInterface
{
name = 'AddWorkflowToN8nTemplates1756990000000';
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
await queryRunner.dropColumn('n8n_templates', 'workflow');
console.log('✅ Dropped workflow column from n8n_templates table');
}
}