"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeedGroup1558006505982 = void 0;
const board_service_1 = require("@things-factory/board-service");
const shell_1 = require("@things-factory/shell");
const SEED_GROUP = [
    {
        name: 'LABEL',
        description: 'LABEL'
    },
    {
        name: 'WAREHOUSE',
        description: 'WAREHOUSE'
    },
    {
        name: 'LOGISTICS',
        description: 'LOGISTICS'
    }
];
class SeedGroup1558006505982 {
    async up(queryRunner) {
        const repository = (0, shell_1.getRepository)(board_service_1.Group);
        const domainRepository = (0, shell_1.getRepository)(shell_1.Domain);
        const domain = await domainRepository.findOneBy({ subdomain: 'system' });
        return await Promise.all(SEED_GROUP.map(async (group) => {
            await repository.save({
                ...group,
                domain
            });
        }));
    }
    async down(queryRunner) {
        const repository = (0, shell_1.getRepository)(board_service_1.Group);
        return await Promise.all(SEED_GROUP.reverse().map(async (group) => {
            let record = await repository.findOneBy({ name: group.name });
            await repository.remove(record);
        }));
    }
}
exports.SeedGroup1558006505982 = SeedGroup1558006505982;
//# sourceMappingURL=1558006505982-SeedGroup.js.map