Passed
Pull Request — master (#157)
by Mathieu
01:42
created

server/migrations/1605272527582-CooperativeSettings.ts   A

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 CooperativeSettings1605272527582.up 0 6 1
A CooperativeSettings1605272527582.down 0 4 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class CooperativeSettings1605272527582 implements MigrationInterface {
4
    name = 'CooperativeSettings1605272527582'
5
6
    public async up(queryRunner: QueryRunner): Promise<void> {
7
        await queryRunner.query(`CREATE TABLE "cooperative" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "dayDuration" integer NOT NULL DEFAULT 420, "addressId" uuid NOT NULL, CONSTRAINT "PK_b53942b37eb26a5d32a9a6ed455" PRIMARY KEY ("id"))`);
8
        await queryRunner.query(`ALTER TABLE "cooperative" ADD CONSTRAINT "FK_76076f95b4afaa794ca4a974661" FOREIGN KEY ("addressId") REFERENCES "address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
9
        await queryRunner.query(`INSERT INTO "address" VALUES('d784e499-1242-471c-9590-d3f77d1919ec', '2 rue Dieu', 'Paris', '75010', 'FR')`, undefined);
10
        await queryRunner.query(`INSERT INTO "cooperative" VALUES('863f007e-7490-4a8d-8f78-27230791de8d', 'Fairness', 420, 'd784e499-1242-471c-9590-d3f77d1919ec')`, undefined);
11
    }
12
13
    public async down(queryRunner: QueryRunner): Promise<void> {
14
        await queryRunner.query(`ALTER TABLE "cooperative" DROP CONSTRAINT "FK_76076f95b4afaa794ca4a974661"`);
15
        await queryRunner.query(`DROP TABLE "cooperative"`);
16
    }
17
18
}
19