Passed
Push — master ( 8559eb...809b5e )
by Mathieu
01:54
created

api/migrations/1622379534005-ProductWeight.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 17
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ProductWeight1622379534005.down 0 4 1
A ProductWeight1622379534005.up 0 4 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class ProductWeight1622379534005 implements MigrationInterface {
4
    name = 'ProductWeight1622379534005'
5
6
    public async up(queryRunner: QueryRunner): Promise<void> {
7
        await queryRunner.query(`ALTER TABLE "shipping_cost" RENAME COLUMN "grams" TO "weight"`);
8
        await queryRunner.query(`ALTER TABLE "product" ADD "weight" integer NOT NULL DEFAULT 0`);
9
    }
10
11
    public async down(queryRunner: QueryRunner): Promise<void> {
12
        await queryRunner.query(`ALTER TABLE "product" DROP COLUMN "weight"`);
13
        await queryRunner.query(`ALTER TABLE "shipping_cost" RENAME COLUMN "weight" TO "grams"`);
14
    }
15
16
}
17