export class ScheduledNotes1783700000000 {
    name = "ScheduledNotes1783700000000";
    async up(queryRunner) {
        await queryRunner.query(`CREATE TABLE IF NOT EXISTS "scheduled_note" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "scheduledAt" TIMESTAMP WITH TIME ZONE NOT NULL, "userId" character varying(32) NOT NULL, "status" character varying(16) NOT NULL DEFAULT 'scheduled', "data" jsonb NOT NULL, "noteId" character varying(32), "error" text, CONSTRAINT "PK_scheduled_note" PRIMARY KEY ("id"))`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_scheduled_note_createdAt" ON "scheduled_note" ("createdAt")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_scheduled_note_scheduledAt" ON "scheduled_note" ("scheduledAt")`);
        await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_scheduled_note_userId" ON "scheduled_note" ("userId")`);
        await queryRunner.query(`DO $$ BEGIN ALTER TABLE "scheduled_note" ADD CONSTRAINT "FK_scheduled_note_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 "scheduled_note" ADD CONSTRAINT "FK_scheduled_note_note" FOREIGN KEY ("noteId") REFERENCES "note"("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 "scheduled_note"`);
    }
}
