1
|
|
|
import {MigrationInterface, QueryRunner} from "typeorm"; |
2
|
|
|
|
3
|
|
|
export class FairCalendarEvent1587124202585 implements MigrationInterface { |
4
|
|
|
name = 'FairCalendarEvent1587124202585' |
5
|
|
|
|
6
|
|
|
public async up(queryRunner: QueryRunner): Promise<any> { |
7
|
|
|
await queryRunner.query(`CREATE TYPE "event_type_enum" AS ENUM('mission', 'support', 'dojo', 'holiday', 'formationConference', 'medicalLeave', 'other')`, undefined); |
8
|
|
|
await queryRunner.query(`CREATE TABLE "event" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "event_type_enum" NOT NULL, "time" integer NOT NULL, "date" date NOT NULL, "summary" character varying, "projectId" uuid, "taskId" uuid, "userId" uuid NOT NULL, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))`, undefined); |
9
|
|
|
await queryRunner.query(`ALTER TABLE "event" ADD CONSTRAINT "FK_3dde39f7b276bbc735a0f762ead" FOREIGN KEY ("projectId") REFERENCES "project"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
10
|
|
|
await queryRunner.query(`ALTER TABLE "event" ADD CONSTRAINT "FK_56b239fecbe385af3a3186acab0" FOREIGN KEY ("taskId") REFERENCES "task"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
11
|
|
|
await queryRunner.query(`ALTER TABLE "event" ADD CONSTRAINT "FK_01cd2b829e0263917bf570cb672" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public async down(queryRunner: QueryRunner): Promise<any> { |
15
|
|
|
await queryRunner.query(`ALTER TABLE "event" DROP CONSTRAINT "FK_01cd2b829e0263917bf570cb672"`, undefined); |
16
|
|
|
await queryRunner.query(`ALTER TABLE "event" DROP CONSTRAINT "FK_56b239fecbe385af3a3186acab0"`, undefined); |
17
|
|
|
await queryRunner.query(`ALTER TABLE "event" DROP CONSTRAINT "FK_3dde39f7b276bbc735a0f762ead"`, undefined); |
18
|
|
|
await queryRunner.query(`DROP TABLE "event"`, undefined); |
19
|
|
|
await queryRunner.query(`DROP TYPE "event_type_enum"`, undefined); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
} |
23
|
|
|
|