All files / projects-dev/apps/mc-api/src/migrations 1664889769228-UpdateMutantCycle.ts

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

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 75 76 77 78 79 80 81 82                                                                                                                                                                   
import {MigrationInterface, QueryRunner} from "typeorm";

export class UpdateMutantCycle1664889769228 implements MigrationInterface {
    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`UPDATE packs SET owned = true WHERE code IN ('MC030', 'MC031')`);

        await queryRunner.query(`
            REPLACE INTO packs VALUES
            ('MC032', 'Mutant Genesis', 'Expansion', '2022-09-30', true),
            ('MC033', 'Cyclops', 'Hero', '2022-09-30', true),
            ('MC034', 'Phoenix', 'Hero', '2022-09-30', true),
            ('MC035', 'Wolverine', 'Hero', '2022-10-30', false),
            ('MC036', 'Storm', 'Hero', '2022-10-30', false),
            ('MC039', 'Mojo Mania', 'Scenario', '2023-01-30', false);
        `);

        await queryRunner.query(`
            REPLACE INTO heroes VALUES
            (55, 'Colossus', 'Piotr Rasputin', 'Protection', 'MC032'),
            (56, 'Shadowcat', 'Kitty Pryde', 'Aggression', 'MC032'),
            (57, 'Cyclops', 'Scott Summers', 'Leadership', 'MC033'),
            (58, 'Phoenix', 'Jean Grey', 'Justice', 'MC034'),
            (59, 'Wolverine', 'Logan', 'Aggression', 'MC035'),
            (60, 'Storm', 'Ororo Munroe', 'Leadership', 'MC036');
        `);

        await queryRunner.query(`
            REPLACE INTO scenarios VALUES
            (36, 'Sabretooth - Stalked by Sabretooth', 'MC032'),
            (37, 'Sentinel - Project Wideawake', 'MC032'),
            (38, 'Master Mold - The Sentinel Factory', 'MC032'),
            (39, 'Mansion Attack', 'MC032'),
            (40, 'Magneto - Asteroid M', 'MC032'),
            (41, 'Magog', 'MC039'),
            (42, 'Spiral', 'MC039'),
            (43, 'Mojo', 'MC039');
        `);

        await queryRunner.query(`
            REPLACE INTO modular_sets VALUES
            (65, 'Mystique', 'MC032'),
            (66, 'Brotherhood', 'MC032'),
            (67, 'Operation Zero Tolerance', 'MC032'),
            (68, 'Sentinels', 'MC032'),
            (69, 'Acolytes', 'MC032'),
            (70, 'Future Past', 'MC032');
        `);

        await queryRunner.query(`
            INSERT INTO scenarios_modular_sets VALUES
            (36, 65),
            (36, 66),
            (37, 67),
            (37, 68),
            (38, 67),
            (38, 68),
            (39, 66),
            (39, 65),
            (40, 69);
        `);

        await queryRunner.query(`UPDATE packs SET owned = true WHERE code LIKE 'MC03%'`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`DELETE FROM scenarios_modular_sets WHERE scenarioId IN (36, 37, 38, 39, 40, 41, 42, 43)`);

        await queryRunner.query(`DELETE FROM modular_sets WHERE id IN (65, 66, 67, 68, 69, 70)`);

        await queryRunner.query(`DELETE FROM scenarios WHERE id IN (36, 37, 38, 39, 40, 41, 42, 43)`);

        await queryRunner.query(`DELETE FROM heroes WHERE id IN (55, 56, 57, 58, 59, 60)`);

        await queryRunner.query(`UPDATE packs SET owned = false WHERE code LIKE 'MC032'`);

        await queryRunner.query(`
            DELETE FROM packs WHERE code IN ('MC033', 'MC034');
        `);
    }

}