All files / projects-dev/apps/mc-api/src/migrations 1652063402365-AddPackOwned.ts

0% Statements 0/18
0% Branches 0/1
0% Functions 0/1
0% Lines 0/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                                     
import { MigrationInterface, QueryRunner } from "typeorm";

export class AddPackOwned1652063402365 implements MigrationInterface {
    public async up(queryRunner: QueryRunner): Promise<void> {
        queryRunner.query(`ALTER TABLE packs ADD COLUMN owned boolean DEFAULT false`);
        queryRunner.query(`UPDATE packs SET owned = true WHERE code LIKE 'CUS%'`);
        queryRunner.query(`UPDATE packs SET owned = true WHERE code LIKE 'PnP%'`);
        queryRunner.query(`UPDATE packs SET owned = true WHERE code LIKE 'MC00%'`);
        queryRunner.query(`UPDATE packs SET owned = true WHERE code LIKE 'MC01%'`);
        queryRunner.query(
            `UPDATE packs SET owned = true WHERE code IN ('MC020', 'MC021', 'MC022', 'MC023', 'MC024', 'MC025', 'MC026')`,
        );
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        queryRunner.query(`ALTER TABLE packs DROP COLUMN owned`);
    }
}