Files
sap-intercompany-worker/prisma/migrations/20260818223337_init/migration.sql
T
GeorgeandClaude Sonnet 5 ca57403663 Initial commit: sap-intercompany-worker
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>
2026-09-16 07:45:57 -05:00

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;