-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from 35C4n0r/feat-prisma-models
Feat prisma models
- Loading branch information
Showing
35 changed files
with
1,333 additions
and
738 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,6 @@ src/.DS_Store | |
/src/geojson-data/ | ||
/src/geoquery.in.data/ | ||
db.mmdb | ||
|
||
|
||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: "3.9" | ||
|
||
services: | ||
postgis: | ||
container_name: geopostgis | ||
image: postgis/postgis:16-3.4-alpine | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_USER=admin | ||
- POSTGRES_DB=gis |
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,85 @@ | ||
-- CreateExtension | ||
CREATE EXTENSION IF NOT EXISTS "fuzzystrmatch"; | ||
|
||
-- CreateExtension | ||
CREATE EXTENSION IF NOT EXISTS "postgis"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "State" ( | ||
"id" SERIAL NOT NULL, | ||
"state_code" INTEGER NOT NULL, | ||
"state_name" TEXT NOT NULL, | ||
"metadata" JSONB, | ||
"geometry" geometry NOT NULL, | ||
|
||
CONSTRAINT "State_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "District" ( | ||
"id" SERIAL NOT NULL, | ||
"district_code" INTEGER NOT NULL, | ||
"district_name" TEXT NOT NULL, | ||
"geometry" geometry NOT NULL, | ||
"metadata" JSONB, | ||
"state_id" INTEGER, | ||
|
||
CONSTRAINT "District_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "SubDistrict" ( | ||
"id" SERIAL NOT NULL, | ||
"subdistrict_code" INTEGER NOT NULL, | ||
"subdistrict_name" TEXT NOT NULL, | ||
"geometry" geometry NOT NULL, | ||
"metadata" JSONB, | ||
"district_id" INTEGER, | ||
"state_id" INTEGER, | ||
|
||
CONSTRAINT "SubDistrict_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Village" ( | ||
"id" SERIAL NOT NULL, | ||
"village_code" SERIAL NOT NULL, | ||
"geometry" geometry NOT NULL, | ||
"village_name" TEXT NOT NULL, | ||
"metadata" JSONB, | ||
"subdistrict_id" INTEGER, | ||
"district_id" INTEGER, | ||
"state_id" INTEGER, | ||
|
||
CONSTRAINT "Village_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "State_state_code_key" ON "State"("state_code"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "State_state_name_key" ON "State"("state_name"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "District_district_code_key" ON "District"("district_code"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "SubDistrict_subdistrict_code_key" ON "SubDistrict"("subdistrict_code"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "District" ADD CONSTRAINT "District_state_id_fkey" FOREIGN KEY ("state_id") REFERENCES "State"("state_code") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubDistrict" ADD CONSTRAINT "SubDistrict_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "District"("district_code") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubDistrict" ADD CONSTRAINT "SubDistrict_state_id_fkey" FOREIGN KEY ("state_id") REFERENCES "State"("state_code") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Village" ADD CONSTRAINT "Village_subdistrict_id_fkey" FOREIGN KEY ("subdistrict_id") REFERENCES "SubDistrict"("subdistrict_code") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Village" ADD CONSTRAINT "Village_district_id_fkey" FOREIGN KEY ("district_id") REFERENCES "District"("district_code") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Village" ADD CONSTRAINT "Village_state_id_fkey" FOREIGN KEY ("state_id") REFERENCES "State"("state_code") ON DELETE SET NULL ON UPDATE CASCADE; |
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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,76 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? | ||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init | ||
|
||
// Command for migration: npx prisma migrate dev --name init | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["postgresqlExtensions"] | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
extensions = [postgis(), fuzzystrmatch()] | ||
} | ||
|
||
model State { | ||
id Int @id @default(autoincrement()) | ||
state_code Int @unique | ||
state_name String @unique | ||
metadata Json? | ||
geometry Unsupported("geometry") | ||
district District[] | ||
subdistrict SubDistrict[] | ||
village Village[] | ||
} | ||
|
||
model District { | ||
id Int @id @default(autoincrement()) | ||
district_code Int @unique | ||
district_name String | ||
geometry Unsupported("geometry") | ||
metadata Json? | ||
state_id Int? | ||
state State? @relation(fields: [state_id], references: [state_code]) | ||
subdistrict SubDistrict[] | ||
village Village[] | ||
} | ||
|
||
model SubDistrict { | ||
id Int @id @default(autoincrement()) | ||
subdistrict_code Int @unique | ||
subdistrict_name String | ||
geometry Unsupported("geometry") | ||
metadata Json? | ||
district_id Int? | ||
district District? @relation(fields: [district_id], references: [district_code]) | ||
state_id Int? | ||
state State? @relation(fields: [state_id], references: [state_code]) | ||
village Village[] | ||
} | ||
|
||
model Village { | ||
id Int @id @default(autoincrement()) | ||
village_code Int @default(autoincrement()) | ||
geometry Unsupported("geometry") | ||
village_name String | ||
metadata Json? | ||
subdistrict_id Int? | ||
subdistrict SubDistrict? @relation(fields: [subdistrict_id], references: [subdistrict_code]) | ||
district_id Int? | ||
district District? @relation(fields: [district_id], references: [district_code]) | ||
state_id Int? | ||
state State? @relation(fields: [state_id], references: [state_code]) | ||
} |
Oops, something went wrong.