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

60 lines
1.4 KiB
TypeScript

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