"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeedPlayGroup1558009487900 = void 0;
const board_service_1 = require("@things-factory/board-service");
const shell_1 = require("@things-factory/shell");
const SEED_PLAY_GROUP = [];
class SeedPlayGroup1558009487900 {
    async up(queryRunner) {
        const repository = (0, shell_1.getRepository)(board_service_1.PlayGroup);
        const domainRepository = (0, shell_1.getRepository)(shell_1.Domain);
        const domain = await domainRepository.findOneBy({ subdomain: 'system' });
        const boardRepository = (0, shell_1.getRepository)(board_service_1.Board);
        const boards = await boardRepository.find();
        return await Promise.all(SEED_PLAY_GROUP.map(async (group) => {
            await repository.save({
                ...group,
                domain,
                boards
            });
        }));
    }
    async down(queryRunner) {
        const repository = (0, shell_1.getRepository)(board_service_1.PlayGroup);
        return await Promise.all(SEED_PLAY_GROUP.reverse().map(async (group) => {
            let record = await repository.findOneBy({ name: group.name });
            // TODO remove cascade
            await repository.remove(record);
        }));
    }
}
exports.SeedPlayGroup1558009487900 = SeedPlayGroup1558009487900;
//# sourceMappingURL=1558009487900-SeedPlayGroup.js.map