-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy path1717147942177-create-notification-table.ts
26 lines (23 loc) · 1.29 KB
/
1717147942177-create-notification-table.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { MigrationInterface, QueryRunner } from 'typeorm';
export class CreateNotificationTable1717147942177
implements MigrationInterface {
name = 'CreateNotificationTable1717147942177';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TYPE "public"."notification_type_enum" AS ENUM('post', 'comment', 'reaction')`
);
await queryRunner.query(
`CREATE TABLE "notification" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."notification_type_enum" NOT NULL, "resourceId" character varying NOT NULL, "message" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "leaveRequestId" uuid, CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY ("id"))`
);
await queryRunner.query(
`ALTER TABLE "notification" ADD CONSTRAINT "FK_d7dcd7fa90cc4542719b880bc7f" FOREIGN KEY ("leaveRequestId") REFERENCES "leave_request"("id") ON DELETE SET NULL ON UPDATE NO ACTION`
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "notification" DROP CONSTRAINT "FK_d7dcd7fa90cc4542719b880bc7f"`
);
await queryRunner.query(`DROP TABLE "notification"`);
await queryRunner.query(`DROP TYPE "public"."notification_type_enum"`);
}
}