Motor de escenarios de replicacion entre bases SAP Business One (Service Layer). Poll periodico sobre webhook_events, escenarios configurables via Prisma (filter + transform por escenario). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
32 lines
1.0 KiB
SQL
32 lines
1.0 KiB
SQL
-- CreateEnum
|
|
CREATE TYPE "EventStatus" AS ENUM ('pending', 'processing', 'done', 'partial', 'failed');
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "webhook_events" (
|
|
"id" TEXT NOT NULL,
|
|
"business_object" TEXT NOT NULL,
|
|
"operation" TEXT NOT NULL,
|
|
"subject" TEXT NOT NULL,
|
|
"payload" JSONB NOT NULL,
|
|
"received_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"status" "EventStatus" NOT NULL DEFAULT 'pending',
|
|
|
|
CONSTRAINT "webhook_events_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "replication_attempts" (
|
|
"id" SERIAL NOT NULL,
|
|
"event_id" TEXT NOT NULL,
|
|
"subsidiary" TEXT NOT NULL,
|
|
"verb_used" TEXT NOT NULL,
|
|
"http_status" INTEGER,
|
|
"error_message" TEXT,
|
|
"attempted_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "replication_attempts_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "replication_attempts" ADD CONSTRAINT "replication_attempts_event_id_fkey" FOREIGN KEY ("event_id") REFERENCES "webhook_events"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|