export class Memoriet1783800000000 {
    name = "Memoriet1783800000000";
    async up(queryRunner) {
        await queryRunner.query(`CREATE TABLE IF NOT EXISTS "memoriet" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "userId" character varying(32) NOT NULL, "noteId" character varying(32) NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE, CONSTRAINT "PK_memoriet" PRIMARY KEY ("id"))`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_memoriet_createdAt" ON "memoriet" ("createdAt")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_memoriet_userId" ON "memoriet" ("userId")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_memoriet_noteId" ON "memoriet" ("noteId")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_memoriet_expiresAt" ON "memoriet" ("expiresAt")`);
        await queryRunner.query(`DO $$ BEGIN ALTER TABLE "memoriet" ADD CONSTRAINT "FK_memoriet_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 "memoriet" ADD CONSTRAINT "FK_memoriet_note" FOREIGN KEY ("noteId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION; EXCEPTION WHEN duplicate_object THEN NULL; END $$`);
    }
    async down(queryRunner) {
        await queryRunner.query(`DROP TABLE IF EXISTS "memoriet"`);
    }
}
