api/migrations/1617724003673-Event.ts   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 19
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
mnd 0
bc 0
fnc 2
dl 0
loc 19
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A Event1617724003673.up 0 5 1
A Event1617724003673.down 0 5 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class Event1617724003673 implements MigrationInterface {
4
    name = 'Event1617724003673'
5
6
    public async up(queryRunner: QueryRunner): Promise<void> {
7
        await queryRunner.query(`CREATE TABLE "event" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "date" TIMESTAMP NOT NULL, "summary" character varying, "schoolId" uuid NOT NULL, "photographerId" uuid NOT NULL, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))`);
8
        await queryRunner.query(`ALTER TABLE "event" ADD CONSTRAINT "FK_e4d1b1384d9f0d65a116523f8bd" FOREIGN KEY ("schoolId") REFERENCES "school"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
9
        await queryRunner.query(`ALTER TABLE "event" ADD CONSTRAINT "FK_b433cf0b27b9d6ec873f07203dd" FOREIGN KEY ("photographerId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
10
    }
11
12
    public async down(queryRunner: QueryRunner): Promise<void> {
13
        await queryRunner.query(`ALTER TABLE "event" DROP CONSTRAINT "FK_b433cf0b27b9d6ec873f07203dd"`);
14
        await queryRunner.query(`ALTER TABLE "event" DROP CONSTRAINT "FK_e4d1b1384d9f0d65a116523f8bd"`);
15
        await queryRunner.query(`DROP TABLE "event"`);
16
    }
17
18
}
19