legacy-direct-sync.sql 1.6 KB

12345678910111213141516171819202122232425262728
  1. CREATE TABLE IF NOT EXISTS "LegacyDirectRun" (
  2. company text NOT NULL, "businessDate" text NOT NULL, "runId" text NOT NULL UNIQUE,
  3. owner text NOT NULL, "leaseUntil" timestamptz NOT NULL, status text NOT NULL DEFAULT 'running',
  4. "startedAt" timestamptz NOT NULL DEFAULT now(), "finishedAt" timestamptz, summary jsonb,
  5. PRIMARY KEY(company,"businessDate")
  6. );
  7. CREATE TABLE IF NOT EXISTS "LegacyDirectBaseline" (
  8. company text NOT NULL, model numeric NOT NULL, gid numeric NOT NULL, fingerprint text NOT NULL,
  9. "updatedAt" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY(company,model,gid)
  10. );
  11. CREATE TABLE IF NOT EXISTS "LegacyDirectBatch" (
  12. company text NOT NULL, "runId" text NOT NULL, key text NOT NULL, fingerprint text NOT NULL,
  13. result jsonb NOT NULL, "createdAt" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY(company,"runId",key)
  14. );
  15. CREATE TABLE IF NOT EXISTS "LegacyDirectEvidence" (
  16. company text NOT NULL, "runId" text NOT NULL, model numeric NOT NULL,
  17. ids jsonb NOT NULL, "sourceCount" numeric NOT NULL, "sourceChecksum" text NOT NULL,
  18. "targetChecksum" text NOT NULL, conflicts numeric NOT NULL, "contentChecksum" text NOT NULL,
  19. PRIMARY KEY(company,"runId",model)
  20. );
  21. REVOKE ALL ON "LegacyDirectRun","LegacyDirectBaseline","LegacyDirectBatch","LegacyDirectEvidence" FROM PUBLIC;
  22. CREATE TABLE IF NOT EXISTS "LegacyDirectSourcePage" (
  23. company text NOT NULL, "runId" text NOT NULL, model numeric NOT NULL, page numeric NOT NULL,
  24. ids jsonb NOT NULL, total numeric NOT NULL, checksum text NOT NULL, "capturedAt" timestamptz NOT NULL DEFAULT now(),
  25. PRIMARY KEY(company,"runId",model,page)
  26. );
  27. REVOKE ALL ON "LegacyDirectSourcePage" FROM PUBLIC;