var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import CaptureSpan from "../../../Utils/Telemetry/CaptureSpan";
export class MigrationName1729682875503 {
    constructor() {
        this.name = "MigrationName1729682875503";
    }
    async up(queryRunner) {
        await queryRunner.query(`CREATE TABLE "Dashboard" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(100) NOT NULL, "slug" character varying(100) NOT NULL, "description" character varying(500), "createdByUserId" uuid, "deletedByUserId" uuid, "dashboardViewConfig" jsonb NOT NULL, CONSTRAINT "PK_98ee748c8a7a18d6f9ca995eaf4" PRIMARY KEY ("_id"))`);
        await queryRunner.query(`CREATE INDEX "IDX_7f0fc9402b8d4151c46e3015a3" ON "Dashboard" ("projectId") `);
        await queryRunner.query(`CREATE TABLE "DashboardLabel" ("dashboardId" uuid NOT NULL, "labelId" uuid NOT NULL, CONSTRAINT "PK_bf2648028a4eab3f57aad76dab6" PRIMARY KEY ("dashboardId", "labelId"))`);
        await queryRunner.query(`CREATE INDEX "IDX_ce2113f43c6d88a632318414d0" ON "DashboardLabel" ("dashboardId") `);
        await queryRunner.query(`CREATE INDEX "IDX_31a32c8d6d1d1cb734c7711050" ON "DashboardLabel" ("labelId") `);
        await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`);
        await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`);
        await queryRunner.query(`ALTER TABLE "Dashboard" ADD CONSTRAINT "FK_7f0fc9402b8d4151c46e3015a30" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "Dashboard" ADD CONSTRAINT "FK_501b2bb8e0cb03f309211cbfa5f" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "Dashboard" ADD CONSTRAINT "FK_0debc7bed011eac37da40e875cb" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "DashboardLabel" ADD CONSTRAINT "FK_ce2113f43c6d88a632318414d0d" FOREIGN KEY ("dashboardId") REFERENCES "Dashboard"("_id") ON DELETE CASCADE ON UPDATE CASCADE`);
        await queryRunner.query(`ALTER TABLE "DashboardLabel" ADD CONSTRAINT "FK_31a32c8d6d1d1cb734c77110509" FOREIGN KEY ("labelId") REFERENCES "Label"("_id") ON DELETE CASCADE ON UPDATE CASCADE`);
    }
    async down(queryRunner) {
        await queryRunner.query(`ALTER TABLE "DashboardLabel" DROP CONSTRAINT "FK_31a32c8d6d1d1cb734c77110509"`);
        await queryRunner.query(`ALTER TABLE "DashboardLabel" DROP CONSTRAINT "FK_ce2113f43c6d88a632318414d0d"`);
        await queryRunner.query(`ALTER TABLE "Dashboard" DROP CONSTRAINT "FK_0debc7bed011eac37da40e875cb"`);
        await queryRunner.query(`ALTER TABLE "Dashboard" DROP CONSTRAINT "FK_501b2bb8e0cb03f309211cbfa5f"`);
        await queryRunner.query(`ALTER TABLE "Dashboard" DROP CONSTRAINT "FK_7f0fc9402b8d4151c46e3015a30"`);
        await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`);
        await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`);
        await queryRunner.query(`DROP INDEX "public"."IDX_31a32c8d6d1d1cb734c7711050"`);
        await queryRunner.query(`DROP INDEX "public"."IDX_ce2113f43c6d88a632318414d0"`);
        await queryRunner.query(`DROP TABLE "DashboardLabel"`);
        await queryRunner.query(`DROP INDEX "public"."IDX_7f0fc9402b8d4151c46e3015a3"`);
        await queryRunner.query(`DROP TABLE "Dashboard"`);
    }
}
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], MigrationName1729682875503.prototype, "up", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], MigrationName1729682875503.prototype, "down", null);
//# sourceMappingURL=1729682875503-MigrationName.js.map