Members register via email+password (scrypt) or Google OAuth — same signed-cookie + scrypt pattern as LokiLab (lib/auth.ts, member-password.ts, member-auth.ts, google-oauth.ts), own AUTH_SECRET and own OAuth client, own dedicated Postgres database (lokiloto-db on Coolify), fully isolated from LokiLab's own DB and auth. Leaderboard tracks who follows Loki's picks most accurately — members star a pick from the results panel (FollowButton), resolution reuses LokiLab's own lastDraw.won, no money or pooled play involved anywhere. Leaderboard page renders a horizontal bar chart (recharts) plus a ranked list. Profile page: public nickname (required to appear on the leaderboard), list of followed picks. Header now carries nav + a user menu (avatar dropdown when signed in, "Connexion" button otherwise). Dockerfile runs prisma migrate deploy at container start via docker-entrypoint.sh, same pattern as LokiLab. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
46 lines
1.4 KiB
SQL
46 lines
1.4 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "User" (
|
|
"id" TEXT NOT NULL,
|
|
"email" TEXT NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"avatarUrl" TEXT,
|
|
"googleSub" TEXT,
|
|
"passwordHash" TEXT,
|
|
"publicNickname" TEXT,
|
|
"favoriteCountry" TEXT NOT NULL DEFAULT 'CA-QC',
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "FollowedPick" (
|
|
"id" TEXT NOT NULL,
|
|
"userId" TEXT NOT NULL,
|
|
"lotteryId" TEXT NOT NULL,
|
|
"country" TEXT NOT NULL,
|
|
"targetDrawDate" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "FollowedPick_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "User_googleSub_key" ON "User"("googleSub");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "FollowedPick_userId_idx" ON "FollowedPick"("userId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "FollowedPick_lotteryId_targetDrawDate_idx" ON "FollowedPick"("lotteryId", "targetDrawDate");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "FollowedPick_userId_lotteryId_targetDrawDate_key" ON "FollowedPick"("userId", "lotteryId", "targetDrawDate");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "FollowedPick" ADD CONSTRAINT "FollowedPick_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|