Skip to content

Commit

Permalink
added edit profile
Browse files Browse the repository at this point in the history
  • Loading branch information
SiddhantKotak committed Aug 10, 2024
2 parents eac6978 + c2ffc5c commit 98f1cdc
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 158 deletions.
41 changes: 41 additions & 0 deletions backend/prisma/migrations/20240810025710_schema4/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Warnings:
- Added the required column `projectId` to the `Farmer` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Farmer" ADD COLUMN "projectId" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "Project" (
"id" TEXT NOT NULL,
"farmerId" TEXT NOT NULL,
"employeeId" TEXT NOT NULL,
"temperature10" TEXT NOT NULL,
"moisture" TEXT NOT NULL,
"temperature" TEXT NOT NULL,
"ultravioletIndex" TEXT NOT NULL,
"weatherGroup" TEXT NOT NULL,
"weatherDescription" TEXT NOT NULL,
"atmosphericTemprature" TEXT NOT NULL,
"pressure" TEXT NOT NULL,
"humidity" TEXT NOT NULL,
"cloudiness" TEXT NOT NULL,
"rainVolume3hrs" TEXT NOT NULL,
"snowVolume3hrs" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Project_farmerId_key" ON "Project"("farmerId");

-- CreateIndex
CREATE UNIQUE INDEX "Project_employeeId_key" ON "Project"("employeeId");

-- AddForeignKey
ALTER TABLE "Project" ADD CONSTRAINT "Project_farmerId_fkey" FOREIGN KEY ("farmerId") REFERENCES "Farmer"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Project" ADD CONSTRAINT "Project_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
27 changes: 25 additions & 2 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ datasource db {
}

model Employee {
id String @id @default(uuid())
email String @unique
id String @id @default(uuid())
email String @unique
name String
password String
age String
Expand All @@ -24,6 +24,7 @@ model Employee {
state String
country String
Farmer Farmer[]
Project Project[]
}

model Farmer {
Expand All @@ -36,4 +37,26 @@ model Farmer {
number String
location String[]
Employee Employee @relation(fields: [employeeId], references: [id])
Project Project?
projectId String
}

model Project {
id String @id @default(uuid())
Farmer Farmer @relation(fields: [farmerId], references: [id])
farmerId String @unique
Employee Employee @relation(fields: [employeeId], references: [id])
employeeId String @unique
temperature10 String
moisture String
temperature String
ultravioletIndex String
weatherGroup String
weatherDescription String
atmosphericTemprature String
pressure String
humidity String
cloudiness String
rainVolume3hrs String
snowVolume3hrs String
}
2 changes: 2 additions & 0 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Hono } from "hono";
import { cors } from "hono/cors";
import { userRouter } from "./routes/user";
import { farmerRouter } from "./routes/farmer";

const app = new Hono();

app.use("/*", cors());
app.route("/api/v1/user", userRouter);
app.route("/api/v1/farmer", farmerRouter);

export default app;
11 changes: 11 additions & 0 deletions backend/src/routes/farmer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Hono } from "hono";

export const farmerRouter = new Hono<{
Bindings: {
DATABASE_URL: string;
JWT_SECRET: string;
};
Variables: {
userId: string;
};
}>();
Loading

0 comments on commit 98f1cdc

Please sign in to comment.