mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-26 16:07:18 +00:00
107 lines
2.6 KiB
TypeScript
107 lines
2.6 KiB
TypeScript
|
|
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
|
||
|
|
|
||
|
|
export class CreateCommentMigration1634626774513 implements MigrationInterface {
|
||
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
|
|
await queryRunner.createTable(
|
||
|
|
new Table({
|
||
|
|
name: 'comments',
|
||
|
|
columns: [
|
||
|
|
{
|
||
|
|
name: 'id',
|
||
|
|
type: 'uuid',
|
||
|
|
isGenerated: true,
|
||
|
|
default: 'gen_random_uuid()',
|
||
|
|
isPrimary: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'thread_id',
|
||
|
|
type: 'uuid',
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'app_versions_id',
|
||
|
|
type: 'uuid',
|
||
|
|
isNullable: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'organization_id',
|
||
|
|
type: 'uuid',
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'comment',
|
||
|
|
type: 'varchar',
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'is_read',
|
||
|
|
type: 'boolean',
|
||
|
|
default: false,
|
||
|
|
isNullable: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'user_id',
|
||
|
|
type: 'uuid',
|
||
|
|
isNullable: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'created_at',
|
||
|
|
type: 'timestamp',
|
||
|
|
isNullable: true,
|
||
|
|
default: 'now()',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'updated_at',
|
||
|
|
type: 'timestamp',
|
||
|
|
isNullable: true,
|
||
|
|
default: 'now()',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
}),
|
||
|
|
true
|
||
|
|
);
|
||
|
|
|
||
|
|
await queryRunner.createForeignKey(
|
||
|
|
'comments',
|
||
|
|
new TableForeignKey({
|
||
|
|
columnNames: ['user_id'],
|
||
|
|
referencedColumnNames: ['id'],
|
||
|
|
referencedTableName: 'users',
|
||
|
|
onDelete: 'CASCADE',
|
||
|
|
})
|
||
|
|
);
|
||
|
|
|
||
|
|
await queryRunner.createForeignKey(
|
||
|
|
'comments',
|
||
|
|
new TableForeignKey({
|
||
|
|
columnNames: ['thread_id'],
|
||
|
|
referencedColumnNames: ['id'],
|
||
|
|
referencedTableName: 'threads',
|
||
|
|
onDelete: 'CASCADE',
|
||
|
|
})
|
||
|
|
);
|
||
|
|
|
||
|
|
await queryRunner.createForeignKey(
|
||
|
|
'comments',
|
||
|
|
new TableForeignKey({
|
||
|
|
columnNames: ['organization_id'],
|
||
|
|
referencedColumnNames: ['id'],
|
||
|
|
referencedTableName: 'organizations',
|
||
|
|
onDelete: 'CASCADE',
|
||
|
|
})
|
||
|
|
);
|
||
|
|
|
||
|
|
await queryRunner.createForeignKey(
|
||
|
|
'comments',
|
||
|
|
new TableForeignKey({
|
||
|
|
columnNames: ['app_versions_id'],
|
||
|
|
referencedColumnNames: ['id'],
|
||
|
|
referencedTableName: 'app_versions',
|
||
|
|
onDelete: 'CASCADE',
|
||
|
|
})
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public async down(_queryRunner: QueryRunner): Promise<void> {}
|
||
|
|
}
|