Passed
Pull Request — master (#56)
by
unknown
03:10 queued 01:29
created

api/migrations/1620379228495-Ingestion.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
eloc 14
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
mnd 0
bc 0
fnc 2
bpm 0
cpm 1
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A Ingestion1620379228495.down 0 5 1
A Ingestion1620379228495.up 0 5 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class Ingestion1620379228495 implements MigrationInterface {
4
    name = 'Ingestion1620379228495'
5
6
    public async up(queryRunner: QueryRunner): Promise<void> {
7
        await queryRunner.query(`CREATE TYPE "ingestion_state_enum" AS ENUM('init', 'upload_started', 'upload_cancelled', 'upload_finished', 'failed')`);
8
        await queryRunner.query(`CREATE TABLE "ingestion" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "state" "ingestion_state_enum" NOT NULL DEFAULT 'init', "schoolId" uuid NOT NULL, CONSTRAINT "PK_c318c071e868a0a37153cabf606" PRIMARY KEY ("id"))`);
9
        await queryRunner.query(`ALTER TABLE "ingestion" ADD CONSTRAINT "FK_bedba27d2f82d30b329ca7248f1" FOREIGN KEY ("schoolId") REFERENCES "school"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
10
    }
11
12
    public async down(queryRunner: QueryRunner): Promise<void> {
13
        await queryRunner.query(`ALTER TABLE "ingestion" DROP CONSTRAINT "FK_bedba27d2f82d30b329ca7248f1"`);
14
        await queryRunner.query(`DROP TABLE "ingestion"`);
15
        await queryRunner.query(`DROP TYPE "ingestion_state_enum"`);
16
    }
17
18
}
19