ToolJet/server/migrations/1656312830147-CreateCommentUsers.ts

64 lines
1.6 KiB
TypeScript
Raw Normal View History

import { MigrationInterface, QueryRunner, Table } from 'typeorm';
export class CreateCommentUsers1656312830147 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'comment_users',
columns: [
{
name: 'id',
type: 'uuid',
isGenerated: true,
default: 'gen_random_uuid()',
isPrimary: true,
},
{
name: 'comment_id',
type: 'uuid',
isNullable: false,
},
{
name: 'user_id',
type: 'uuid',
isNullable: false,
},
{
name: 'is_read',
type: 'boolean',
default: false,
isNullable: true,
},
{
name: 'created_at',
type: 'timestamp',
isNullable: true,
default: 'now()',
},
{
name: 'updated_at',
type: 'timestamp',
isNullable: true,
default: 'now()',
},
],
foreignKeys: [
{
referencedTableName: 'users',
referencedColumnNames: ['id'],
columnNames: ['user_id'],
},
{
referencedTableName: 'comments',
referencedColumnNames: ['id'],
columnNames: ['comment_id'],
},
],
}),
true
);
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}