Skip to content

Commit

Permalink
Merge branch 'dev' into dependabot/github_actions/actions/upload-arti…
Browse files Browse the repository at this point in the history
…fact-4
  • Loading branch information
newsroomdev authored Mar 29, 2024
2 parents 674c3e9 + 23782f1 commit 2ea16c0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

# Make sure to override these in deployment
DATABASE_URL="postgresql://postgres:@localhost:5432/trpc-starter-websockets?schema=public"
DATABASE_URL="postgresql://postgres:@localhost:5432/electionsdata?schema=public"
APP_URL="http://localhost:3000"
WS_URL="ws://localhost:3001"
NEXTAUTH_URL="http://localhost:3000/api/auth"
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ This is a full-stack React application built with Next.js, Prisma, and tRPC with
- ✅ E2E testing with [Playwright](https://playwright.dev/)
- ✅ Linting

## Requirements

This project uses [Node.js](https://nodejs.org/en) and [PNPM](https://pnpm.io).

It also requires a local PostgreSQL database for development, which Prisma will use to create, migrate and read from a schema.

## Getting Started

First, install the dependencies:
Before you begin, `cp .env .env.local` in the project and adjust the connection string to match your local PostgreSQL setup, e.g. `DATABASE_URL="postgresql://<YOUR_USER>:<YOUR_PASSWORD>@localhost:5432..."`, making sure these credentials allow you to create and modify databases.

Next, install the dependencies:

```sh
pnpm install
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- CreateEnum
CREATE TYPE "ElectionType" AS ENUM ('PRESIDENTIAL', 'PARLIAMENTARY');

-- CreateTable
CREATE TABLE "Country" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"isoCode" TEXT NOT NULL,

CONSTRAINT "Country_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Election" (
"id" TEXT NOT NULL,
"countryId" TEXT NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"pollClose" TIMESTAMP(3) NOT NULL,
"type" "ElectionType" NOT NULL,
"notes" TEXT,
"eta" TEXT,
"dataSource" TEXT NOT NULL,
"dataUrl" TEXT NOT NULL,

CONSTRAINT "Election_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ElectionResult" (
"id" TEXT NOT NULL,
"electionId" TEXT NOT NULL,
"candidate" TEXT,
"party" TEXT,
"votes" INTEGER NOT NULL,
"percentage" DOUBLE PRECISION,

CONSTRAINT "ElectionResult_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Country_name_key" ON "Country"("name");

-- CreateIndex
CREATE UNIQUE INDEX "Country_isoCode_key" ON "Country"("isoCode");

-- AddForeignKey
ALTER TABLE "Election" ADD CONSTRAINT "Election_countryId_fkey" FOREIGN KEY ("countryId") REFERENCES "Country"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ElectionResult" ADD CONSTRAINT "ElectionResult_electionId_fkey" FOREIGN KEY ("electionId") REFERENCES "Election"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

0 comments on commit 2ea16c0

Please sign in to comment.