first MVP

This commit is contained in:
Maxime Van Hees
2025-11-14 21:07:10 +01:00
parent 31327c9969
commit 4d024a39f4
26 changed files with 2729 additions and 64 deletions

View File

@@ -0,0 +1,43 @@
-- CreateTable
CREATE TABLE "Person" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"company" TEXT,
"role" TEXT,
"email" TEXT,
"location" TEXT,
"sectors" TEXT[] DEFAULT ARRAY[]::TEXT[],
"interests" TEXT[] DEFAULT ARRAY[]::TEXT[],
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Person_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Connection" (
"id" TEXT NOT NULL,
"personAId" TEXT NOT NULL,
"personBId" TEXT NOT NULL,
"introducedByChain" TEXT[] DEFAULT ARRAY[]::TEXT[],
"eventLabels" TEXT[] DEFAULT ARRAY[]::TEXT[],
"notes" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Connection_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Person_name_idx" ON "Person"("name");
-- CreateIndex
CREATE INDEX "Connection_personAId_idx" ON "Connection"("personAId");
-- CreateIndex
CREATE INDEX "Connection_personBId_idx" ON "Connection"("personBId");
-- AddForeignKey
ALTER TABLE "Connection" ADD CONSTRAINT "Connection_personAId_fkey" FOREIGN KEY ("personAId") REFERENCES "Person"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Connection" ADD CONSTRAINT "Connection_personBId_fkey" FOREIGN KEY ("personBId") REFERENCES "Person"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -0,0 +1,14 @@
-- Enforce undirected connection uniqueness and prevent self-edges
-- Prevent self-edge (A == B)
ALTER TABLE "Connection"
ADD CONSTRAINT "Connection_no_self_edge"
CHECK ("personAId" <> "personBId");
-- Unique undirected pair using functional index on LEAST/GREATEST
-- Ensures only one edge exists for a given unordered pair {A,B}
CREATE UNIQUE INDEX IF NOT EXISTS "Connection_undirected_pair_unique"
ON "Connection" (
(LEAST("personAId","personBId")),
(GREATEST("personAId","personBId"))
);

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"