Passed
Pull Request — master (#146)
by Mathieu
02:09
created

FairCalendarEvent1587124202585   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 17
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A up 0 7 1
A down 0 7 1
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