-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into dependabot/github_actions/actions/upload-arti…
…fact-4
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
prisma/migrations/20240324122939_create_initial_schema/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |