UNPKG

@grouparoo/core

Version:
31 lines (30 loc) 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { up: async (queryInterface, DataTypes) => { const [apps] = await queryInterface.sequelize.query(`SELECT * FROM "apps" WHERE type = 'manual'`); for (const app of apps) { const [sources] = await queryInterface.sequelize.query(`SELECT * FROM "sources" WHERE "appId" = '${app["id"]}'`); for (const source of sources) { const [properties] = await queryInterface.sequelize.query(`SELECT * FROM "properties" WHERE "sourceId" = '${source["id"]}'`); for (const property of properties) { await queryInterface.sequelize.query(`DELETE FROM "runs" WHERE "creatorId" = '${property["id"]}'`); await queryInterface.sequelize.query(`DELETE FROM "options" WHERE "ownerId" = '${property["id"]}' AND "ownerType" = 'property'`); await queryInterface.sequelize.query(`DELETE FROM "filters" WHERE "ownerId" = '${property["id"]}' AND "ownerType" = 'property'`); await queryInterface.sequelize.query(`DELETE FROM "profileProperties" WHERE "propertyId" = '${property["id"]}'`); await queryInterface.sequelize.query(`DELETE FROM "groupRules" WHERE "propertyId" = '${property["id"]}'`); await queryInterface.sequelize.query(`DELETE FROM "mappings" WHERE "propertyId" = '${property["id"]}'`); await queryInterface.sequelize.query(`DELETE FROM "properties" WHERE "id" = '${property["id"]}'`); } await queryInterface.sequelize.query(`DELETE FROM "options" WHERE "ownerId" = '${source["id"]}' AND "ownerType" = 'source'`); await queryInterface.sequelize.query(`DELETE FROM "mappings" WHERE "ownerId" = '${source["id"]}'`); await queryInterface.sequelize.query(`DELETE FROM "sources" WHERE "id" = '${source["id"]}'`); } await queryInterface.sequelize.query(`DELETE FROM "options" WHERE "ownerId" = '${app["id"]}' AND "ownerType" = 'app'`); await queryInterface.sequelize.query(`DELETE FROM "apps" WHERE "id" = '${app["id"]}'`); } }, down: async (queryInterface) => { throw new Error("irreversible migration"); }, };