ToolJet/server/migrations/1676983958469-CreateWorkflowExecutionEntity.ts
2025-02-25 12:22:50 +05:30

68 lines
1.7 KiB
TypeScript

import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
export class CreateWorkflowExecutionEntity1676983958469 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'workflow_executions',
columns: [
{
name: 'id',
type: 'uuid',
isGenerated: true,
default: 'gen_random_uuid()',
isPrimary: true,
},
{
name: 'executing_user_id',
type: 'uuid',
isNullable: true,
},
{
name: 'app_version_id',
type: 'uuid',
isNullable: false,
},
{
name: 'executed',
type: 'boolean',
isNullable: false,
default: false,
},
{
name: 'logs',
type: 'json',
isNullable: true,
},
{
name: 'created_at',
type: 'timestamp',
isNullable: true,
default: 'now()',
},
{
name: 'updated_at',
type: 'timestamp',
isNullable: true,
default: 'now()',
},
],
}),
true
);
await queryRunner.createForeignKey(
'workflow_executions',
new TableForeignKey({
columnNames: ['app_version_id'],
referencedColumnNames: ['id'],
referencedTableName: 'app_versions',
onDelete: 'CASCADE',
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('workflow_executions');
}
}