- 新增TemplateExecutionEntity实体替代原有的GenerationTask方式 - 实现模板执行记录的完整生命周期管理,包含状态跟踪和性能指标 - 添加模板管理的完整CRUD操作API(创建、更新、删除、查询) - 更新数据库迁移文件,包含n8n_templates和template_executions表 - 完善模板工厂服务,支持执行记录管理和统计分析 - 重构DynamicN8nImageTemplate和DynamicN8nVideoTemplate类名 - 添加用户相关实体:User、PlatformUser、ExtensionData、UserCredit等 - 实现完整的数据库表结构和索引优化
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||
|
||
/**
|
||
* 创建扩展数据表
|
||
* 用于存储各平台特有的业务数据和第三方集成数据
|
||
* 提供灵活的JSON存储机制,支持动态数据结构
|
||
*/
|
||
export class CreateExtensionDataTable1725504000000 implements MigrationInterface {
|
||
name = 'CreateExtensionDataTable1725504000000';
|
||
|
||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
// 创建扩展数据表 - 灵活存储各平台特有业务数据
|
||
await queryRunner.query(`
|
||
CREATE TABLE "extension_data" (
|
||
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||
"userId" uuid NOT NULL,
|
||
"platform" "platform_type" NOT NULL,
|
||
"dataType" character varying(50) NOT NULL,
|
||
"referenceId" character varying(100),
|
||
"data" json NOT NULL,
|
||
"metadata" json,
|
||
"status" character varying(20) NOT NULL DEFAULT 'active',
|
||
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
||
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
|
||
CONSTRAINT "PK_extension_data_id" PRIMARY KEY ("id"),
|
||
CONSTRAINT "FK_extension_data_userId" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE
|
||
)
|
||
`);
|
||
}
|
||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||
await queryRunner.query(`DROP TABLE "extension_data"`);
|
||
}
|
||
} |