Files
XRayPDF/client/prisma/migrations/20260718000000_init/migration.sql
T
Aryan SinghandClaude Opus 5 7e7e4d9b1c Make the container actually deployable, publish to GHCR
The Docker setup built but never came up. Three separate blockers, each
found by running the full compose stack against a real Postgres:

- The runner stage hand-copied prisma/@prisma/dotenv, which misses the
  CLI's transitive deps (valibot) and crash-looped the entrypoint. A
  dedicated migrator stage now installs the CLI at the exact lockfile
  version with its real dependency tree.
- Docker sets HOSTNAME to the container id and Next's standalone server
  binds to it verbatim, so the app was unreachable on localhost inside
  the container and the healthcheck could never pass. Pinned to 0.0.0.0.
- openssl was missing from the build stages but present at runtime, so
  Prisma detected a different platform and tried to download a matching
  query engine at boot, as an unprivileged user, into a root-owned
  directory. Aligned openssl across every stage that touches Prisma.

Verified from a clean volume: migrations apply, both containers report
healthy, /api/health returns 200, and the app serves from the image.

Also:
- Publish multi-arch images to GHCR on push to main and on v* tags, with
  an SBOM and a signed provenance attestation.
- Default compose to the published image; add a build override for
  working on the app itself. Host port and image are configurable.
- Drop two unused dependencies: canvas (19MB of native node-canvas; the
  pipeline uses @napi-rs/canvas) and multer (routes use formData()).
- Add a root .gitignore. There wasn't one, so a real .env was one
  `git add .` away from being committed. Untrack .DS_Store.
- Rewrite the README around what the tool does and how to run it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-01 23:54:57 -05:00

63 lines
1.8 KiB
SQL

-- CreateSchema
CREATE SCHEMA IF NOT EXISTS "public";
-- CreateTable
CREATE TABLE "user" (
"id" TEXT NOT NULL,
"email" TEXT NOT NULL,
"name" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "pdfDocument" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"originalName" TEXT NOT NULL,
"filePath" TEXT NOT NULL,
"pixelResultDir" TEXT,
"ocrResultDir" TEXT,
"ocrRan" BOOLEAN NOT NULL DEFAULT false,
"fileSize" INTEGER NOT NULL,
"pageCount" INTEGER NOT NULL DEFAULT 1,
"pixelPageCount" INTEGER NOT NULL DEFAULT 0,
"ocrPageCount" INTEGER NOT NULL DEFAULT 0,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "pdfDocument_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "pdfPage" (
"id" TEXT NOT NULL,
"documentId" TEXT NOT NULL,
"pageNumber" INTEGER NOT NULL,
"confidence" DOUBLE PRECISION NOT NULL,
"wordsJson" JSONB NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "pdfPage_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
-- CreateIndex
CREATE INDEX "pdfDocument_userId_idx" ON "pdfDocument"("userId");
-- CreateIndex
CREATE INDEX "pdfPage_documentId_idx" ON "pdfPage"("documentId");
-- CreateIndex
CREATE UNIQUE INDEX "pdfPage_documentId_pageNumber_key" ON "pdfPage"("documentId", "pageNumber");
-- AddForeignKey
ALTER TABLE "pdfDocument" ADD CONSTRAINT "pdfDocument_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pdfPage" ADD CONSTRAINT "pdfPage_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "pdfDocument"("id") ON DELETE CASCADE ON UPDATE CASCADE;