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

server/migrations/1587385769133-DailyRate.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 21
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
A DailyRate1587385769133.down 0 6 1
A DailyRate1587385769133.up 0 6 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class DailyRate1587385769133 implements MigrationInterface {
4
    name = 'DailyRate1587385769133'
5
6
    public async up(queryRunner: QueryRunner): Promise<any> {
7
        await queryRunner.query(`CREATE TABLE "daily_rate" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "amount" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "userId" uuid NOT NULL, "customerId" uuid NOT NULL, "taskId" uuid NOT NULL, CONSTRAINT "PK_e61570c7fbd239a42b77d44b5d7" PRIMARY KEY ("id"))`, undefined);
8
        await queryRunner.query(`ALTER TABLE "daily_rate" ADD CONSTRAINT "FK_8d819ca9e2a6d7c09e35bd3a2df" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined);
9
        await queryRunner.query(`ALTER TABLE "daily_rate" ADD CONSTRAINT "FK_55d9b1674de0a89daff62e84a27" FOREIGN KEY ("customerId") REFERENCES "customer"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined);
10
        await queryRunner.query(`ALTER TABLE "daily_rate" ADD CONSTRAINT "FK_ec8d839079b34c959733417b1f2" FOREIGN KEY ("taskId") REFERENCES "task"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined);
11
    }
12
13
    public async down(queryRunner: QueryRunner): Promise<any> {
14
        await queryRunner.query(`ALTER TABLE "daily_rate" DROP CONSTRAINT "FK_ec8d839079b34c959733417b1f2"`, undefined);
15
        await queryRunner.query(`ALTER TABLE "daily_rate" DROP CONSTRAINT "FK_55d9b1674de0a89daff62e84a27"`, undefined);
16
        await queryRunner.query(`ALTER TABLE "daily_rate" DROP CONSTRAINT "FK_8d819ca9e2a6d7c09e35bd3a2df"`, undefined);
17
        await queryRunner.query(`DROP TABLE "daily_rate"`, undefined);
18
    }
19
20
}
21