import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm'; export class CreateWorkflowExecutionEntity1676983958469 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { 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 { await queryRunner.dropTable('workflow_executions'); } }