export class VerifiedBadgeRequests1783821000000 {
    name = "VerifiedBadgeRequests1783821000000";
    async up(queryRunner) {
        await queryRunner.query(`CREATE TABLE IF NOT EXISTS "verified_badge_request" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "resolvedAt" TIMESTAMP WITH TIME ZONE, "userId" character varying(32) NOT NULL, "resolverId" character varying(32), "status" character varying(16) NOT NULL DEFAULT 'pending', "comment" character varying(2048) NOT NULL DEFAULT '', CONSTRAINT "PK_verified_badge_request" PRIMARY KEY ("id"))`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_verified_badge_request_createdAt" ON "verified_badge_request" ("createdAt")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_verified_badge_request_userId" ON "verified_badge_request" ("userId")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_verified_badge_request_status" ON "verified_badge_request" ("status")`);
        await queryRunner.query(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_verified_badge_request_user_pending" ON "verified_badge_request" ("userId") WHERE "status" = 'pending'`);
        await queryRunner.query(`DO $$ BEGIN ALTER TABLE "verified_badge_request" ADD CONSTRAINT "FK_verified_badge_request_user" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION; EXCEPTION WHEN duplicate_object THEN NULL; END $$`);
        await queryRunner.query(`DO $$ BEGIN ALTER TABLE "verified_badge_request" ADD CONSTRAINT "FK_verified_badge_request_resolver" FOREIGN KEY ("resolverId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION; EXCEPTION WHEN duplicate_object THEN NULL; END $$`);
    }
    async down(queryRunner) {
        await queryRunner.query(`DROP TABLE IF EXISTS "verified_badge_request"`);
    }
}
