migrations/1650636333167-UserSavingsRecord.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
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A UserSavingsRecord1650636333167.down 0 5 1
A UserSavingsRecord1650636333167.up 0 5 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class UserSavingsRecord1650636333167 implements MigrationInterface {
4
    name = 'UserSavingsRecord1650636333167'
5
6
    public async up(queryRunner: QueryRunner): Promise<void> {
7
        await queryRunner.query(`CREATE TYPE "user_savings_record_type_enum" AS ENUM('input', 'output')`);
8
        await queryRunner.query(`CREATE TABLE "user_savings_record" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "amount" integer NOT NULL, "type" "user_savings_record_type_enum" NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "userId" uuid NOT NULL, CONSTRAINT "PK_f5f68a0ad3332f08e8adc70a4c6" PRIMARY KEY ("id")); COMMENT ON COLUMN "user_savings_record"."amount" IS 'Stored in base 100'`);
9
        await queryRunner.query(`ALTER TABLE "user_savings_record" ADD CONSTRAINT "FK_b126b5220c39f0c684fd3929eac" FOREIGN KEY ("userId") 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 "user_savings_record" DROP CONSTRAINT "FK_b126b5220c39f0c684fd3929eac"`);
14
        await queryRunner.query(`DROP TABLE "user_savings_record"`);
15
        await queryRunner.query(`DROP TYPE "user_savings_record_type_enum"`);
16
    }
17
18
}
19