All files / projects-dev/apps/mc-api/src/migrations 1636796359078-AddNewCustomPacks.ts

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

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 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74                                                                                                                                                   
import { MigrationInterface, QueryRunner } from "typeorm";

export class AddNewCustomPacks1636796359078 implements MigrationInterface {
    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            REPLACE INTO packs VALUES
            ('CUS06', 'Kraven The Hunter', 'Custom', '2021-11-13'),
            ('CUS07', 'Mysterio', 'Custom', '2021-11-13'),
            ('CUS08', 'Angela', 'Custom', '2021-11-13'),
            ('CUS09', 'Yondu', 'Custom', '2021-11-13'),
            ('CUS10', 'Batman', 'Custom', '2021-11-13'),
            ('CUS11', 'Flash', 'Custom', '2021-11-13'),
            ('CUS12', 'Cyborg', 'Custom', '2021-11-13'),
            ('CUS13', 'Galactus', 'Custom', '2021-11-13');
        `);

        await queryRunner.query(`
            REPLACE INTO heroes (id, name, alterEgo, aspects, packCode) VALUES
            (35, 'Angela', 'Aldrif Odinsdottir', null, 'CUS08'),
            (36, 'Yondu', 'Yondu Udonta', null, 'CUS09'),
            (37, 'Batman', 'Bruce Wayne', null, 'CUS10'),
            (38, 'Flash', 'Barry Allen', null, 'CUS11'),
            (39, 'Cyborg', 'Victor Stone', null, 'CUS12');
        `);

        await queryRunner.query(`
            REPLACE INTO modular_sets VALUES
            (39, 'Trap', 'CUS06'),
            (40, 'Savage Six', 'CUS06'),
            (41, 'Behind The Mask', 'CUS07'),
            (42, 'Save THe City', 'CUS13'),
            (43, 'Galactus Cataclysm', 'CUS13'),
            (44, 'Heralds of Galactus', 'CUS13');
        `);

        await queryRunner.query(`
            REPLACE INTO scenarios VALUES
            (24, 'Kraven The Hunter - Aquiring Targets', 'CUS06'),
            (25, 'Mysterio - Mysterious Ways', 'CUS07'),
            (26, 'Galactus - Devour The Earth', 'CUS13');
        `);

        await queryRunner.query(`
            INSERT INTO scenarios_modular_sets VALUES
            (24, 39),
            (24, 40),
            (25, 41),
            (26, 44);
        `);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            DELETE FROM scenarios_modular_sets WHERE scenario IN (24, 25, 26);
        `);

        await queryRunner.query(`
            DELETE FROM scenarios WHERE id IN (24, 25, 26);
        `);

        await queryRunner.query(`
            DELETE FROM modular_sets WHERE id IN (39, 40, 41, 42, 43, 44);
        `);

        await queryRunner.query(`
            DELETE FROM heroes WHERE id IN (35, 36, 37, 38, 39);
        `);

        await queryRunner.query(`
            DELETE FROM packs WHERE code IN ('CUS06', 'CUS07', 'CUS08', 'CUS09', 'CUS10', 'CUS11', 'CUS12', 'CUS13');
        `);
    }
}