-- CreateTable
CREATE TABLE "platform_meeting_attendance"."outlook_sync_event_logs" (
    "id" VARCHAR(32) NOT NULL,
    "binding_id" VARCHAR(32) NOT NULL,
    "mailbox_id" VARCHAR(32) NOT NULL,
    "event_type" VARCHAR(64) NOT NULL,
    "result_status" VARCHAR(32) NOT NULL DEFAULT 'SUCCESS',
    "message" TEXT,
    "payload" JSONB,
    "created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT "outlook_sync_event_logs_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "outlook_sync_event_logs_binding_id_created_at_idx" ON "platform_meeting_attendance"."outlook_sync_event_logs"("binding_id", "created_at");

-- CreateIndex
CREATE INDEX "outlook_sync_event_logs_mailbox_id_created_at_idx" ON "platform_meeting_attendance"."outlook_sync_event_logs"("mailbox_id", "created_at");

-- CreateIndex
CREATE INDEX "outlook_sync_event_logs_event_type_idx" ON "platform_meeting_attendance"."outlook_sync_event_logs"("event_type");

-- AddForeignKey
ALTER TABLE "platform_meeting_attendance"."outlook_sync_event_logs" ADD CONSTRAINT "outlook_sync_event_logs_binding_id_fkey" FOREIGN KEY ("binding_id") REFERENCES "platform_meeting_attendance"."outlook_sync_bindings"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "platform_meeting_attendance"."outlook_sync_event_logs" ADD CONSTRAINT "outlook_sync_event_logs_mailbox_id_fkey" FOREIGN KEY ("mailbox_id") REFERENCES "platform_meeting_attendance"."outlook_sync_mailboxes"("id") ON DELETE CASCADE ON UPDATE CASCADE;
