Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prisma added #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@prisma/client": "^5.14.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-label": "^2.0.2",
Expand All @@ -20,6 +21,7 @@
"clsx": "^2.1.1",
"lucide-react": "^0.378.0",
"next": "14.2.3",
"prisma": "^5.14.0",
"react": "^18",
"react-dom": "^18",
"react-social-media-embed": "^2.5.13",
Expand All @@ -32,6 +34,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"dotenv-cli": "^7.4.2",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"postcss": "^8",
Expand Down
90 changes: 90 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions prisma/migrations/20240522112952_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- CreateTable
CREATE TABLE "Location" (
"id" SERIAL NOT NULL,
"metadata" JSONB NOT NULL,
"location" TEXT NOT NULL,
"location_id" INTEGER NOT NULL,
"courses" JSONB NOT NULL,

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

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"user_name" TEXT NOT NULL,
"user_id" INTEGER NOT NULL,
"role" TEXT NOT NULL,
"email" TEXT NOT NULL,
"location_id" INTEGER NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Location_location_id_key" ON "Location"("location_id");

-- CreateIndex
CREATE UNIQUE INDEX "User_user_id_key" ON "User"("user_id");

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- AddForeignKey
ALTER TABLE "User" ADD CONSTRAINT "User_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "Location"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
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"
27 changes: 27 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
}

model Location {
id Int @id @default(autoincrement())
metadata Json
location String
location_id Int @unique
courses Json
users User[] @relation("LocationUsers")
}

model User {
id Int @id @default(autoincrement())
user_name String
user_id Int @unique
role String
email String @unique
location_id Int
location Location @relation(fields: [location_id], references: [id], name: "LocationUsers")
}
5 changes: 5 additions & 0 deletions src/lib/prisma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export default prisma;