"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "RenameGroupToTag1767432108916", {
    enumerable: true,
    get: function() {
        return RenameGroupToTag1767432108916;
    }
});
class RenameGroupToTag1767432108916 {
    name = 'RenameGroupToTag1767432108916';
    async up(queryRunner) {
        await queryRunner.query(`
      CREATE TABLE "tag"
      (
        "id"   integer PRIMARY KEY AUTOINCREMENT NOT NULL,
        "name" varchar                           NOT NULL,
        "color" varchar
      )
    `);
        await queryRunner.query(`
      INSERT INTO "tag"("id", "name")
      SELECT "id",
             "name"
      FROM "group"
    `);
        await queryRunner.dropTable("group");
        await queryRunner.query(`
      CREATE TABLE "printer_tag"
      (
        "id"        integer PRIMARY KEY AUTOINCREMENT NOT NULL,
        "printerId" integer                           NOT NULL,
        "tagId"     integer                           NOT NULL,
        CONSTRAINT "UQ_639867dded1e0409225feb6d194" UNIQUE ("printerId", "tagId"),
        CONSTRAINT "FK_9be94fa12549808ee97522c7ec0" FOREIGN KEY ("printerId") REFERENCES "printer" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
        CONSTRAINT "FK_f4a342bd378b98caf8727ab88cb" FOREIGN KEY ("tagId") REFERENCES "tag" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
      )
    `);
        await queryRunner.query(`
      INSERT INTO "printer_tag"("id", "printerId", "tagId")
      SELECT "id",
             "printerId",
             "groupId"
      FROM "printer_group"
    `);
        await queryRunner.dropTable("printer_group");
    }
    async down(queryRunner) {
        await queryRunner.query(`
      CREATE TABLE "group"
      (
        "id"   integer PRIMARY KEY AUTOINCREMENT NOT NULL,
        "name" varchar                           NOT NULL
      )
    `);
        await queryRunner.query(`
      INSERT INTO "group"("id", "name")
      SELECT "id",
             "name"
      FROM "tag"
    `);
        await queryRunner.dropTable("tag");
        await queryRunner.query(`
      CREATE TABLE "printer_group"
      (
        "id"        integer PRIMARY KEY AUTOINCREMENT NOT NULL,
        "printerId" integer                           NOT NULL,
        "groupId"   integer                           NOT NULL,
        CONSTRAINT "UQ_639867dded1e0409225feb6d194" UNIQUE ("printerId", "groupId"),
        CONSTRAINT "FK_9be94fa12549808ee97522c7ec0" FOREIGN KEY ("printerId") REFERENCES "printer" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
        CONSTRAINT "FK_f4a342bd378b98caf8727ab88cb" FOREIGN KEY ("groupId") REFERENCES "group" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
      )
    `);
        await queryRunner.query(`
      INSERT INTO "printer_group"("id", "printerId", "groupId")
      SELECT "id",
             "printerId",
             "tagId"
      FROM "printer_tag"
    `);
        await queryRunner.dropTable("printer_tag");
    }
}

//# sourceMappingURL=1767432108916-RenameGroupToTag.js.map