frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

relational data set up incorrectly. [10:05pm] #115

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: deploy. but now fix routes.

error: been using 3-4 pieces of data at a time for 3-4 users. user can only have 1 settings, if they add settings it updates them. {psql.data} is water-cycle data. settings decides weight and height and intake formula and schedule from which data is based.

data.id is corresponding to the user when it should be users_id. this hasn't been a problem having 3-4 days to a user Screen Shot 2023-07-31 at 10 04 25 PM

proposed approach: dismantle prisma and reconfigure.

frankcollins3 commented 1 year ago

prisma/schema.ts:

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

datasource db {
  provider = "postgresql"
  url      = env("NEXT_PUBLIC_DATABASE_URL")
}

model users {
  id            Int         @id @default(autoincrement())
  google_id     String?
  icon          String?
  username      String?
  email         String?
  password      String?
  age           Int?
  settings      settings[]
  data          data[]
}

model settings {
  id         Int      @id @default(autoincrement())  
  users      users    @relation(fields: [id], references: [id])
  age        Int
  height     Int
  weight     Int
  start_time Int
  end_time   Int
  reminder   Int
  activity   Int
  users_id   Int
}

model data {
  id          Int         @id @default(autoincrement())
  users       users       @relation(fields: [id], references: [id])
  google_id   String?
  date        String?
  progress    Int
  weekday     String?
  status      String[]
  users_id    Int
}
frankcollins3 commented 1 year ago

quick fix and the routes work more easily.. just had to: 👍 remove "id" field in prisma.data.create({

[10:33pm]