Passed
Pull Request — master (#316)
by Mathieu
06:06
created

server/migrations/1669989076131-eventEnum.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 eventEnum1669989076131.up 0 6 1
A eventEnum1669989076131.down 0 6 1
1
import { MigrationInterface, QueryRunner } from "typeorm";
2
3
export class eventEnum1669989076131 implements MigrationInterface {
4
    name = 'EventEnum1669989076131'
5
6
    public async up(queryRunner: QueryRunner): Promise<void> {
7
        await queryRunner.query(`ALTER TYPE "public"."event_type_enum" RENAME TO "event_type_enum_old"`);
8
        await queryRunner.query(`CREATE TYPE "public"."event_type_enum" AS ENUM('mission', 'support', 'dojo', 'formationConference', 'admin', 'other')`);
9
        await queryRunner.query(`ALTER TABLE "event" ALTER COLUMN "type" TYPE "public"."event_type_enum" USING "type"::"text"::"public"."event_type_enum"`);
10
        await queryRunner.query(`DROP TYPE "public"."event_type_enum_old"`);
11
    }
12
13
    public async down(queryRunner: QueryRunner): Promise<void> {
14
        await queryRunner.query(`CREATE TYPE "public"."event_type_enum_old" AS ENUM('mission', 'support', 'dojo', 'formationConference', 'other')`);
15
        await queryRunner.query(`ALTER TABLE "event" ALTER COLUMN "type" TYPE "public"."event_type_enum_old" USING "type"::"text"::"public"."event_type_enum_old"`);
16
        await queryRunner.query(`DROP TYPE "public"."event_type_enum"`);
17
        await queryRunner.query(`ALTER TYPE "public"."event_type_enum_old" RENAME TO "event_type_enum"`);
18
    }
19
20
}
21