#schema postgres ERROR: relation "todo" does not exist

4 messages · Page 1 of 1 (latest)

peak flame
#

So I intend to make a todolist app where a user's todos will be saved using cookies. So I create a User model with his userid stored as a cookie and his todolist stored in another model Todo:


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

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

model Todo {
  id         Int     @id @default(autoincrement())
  task       String
  done       Boolean
  User       User?   @relation(fields: [userUserID], references: [userID])
  userUserID Int?
}

model User {
  userID   Int    @unique
  todoList Todo[]
}

I don't see any error in npx prisma format output.
And my db url is:

DATABASE_URL="postgresql://postgres@localhost:5432/posty?schema=public&connection_limit=5"

This is the error I get in my local postgres database on arch linux:

posty=# \dt
               List of relations
 Schema |        Name        | Type  |  Owner   
--------+--------------------+-------+----------
 public | Todo               | table | postgres
 public | User               | table | postgres
 public | _prisma_migrations | table | postgres
(3 rows)

posty=# select * from user;
   user   
----------
 postgres
(1 row)

posty=# select * from todo;
ERROR:  relation "todo" does not exist
LINE 1: select * from todo;
fleet halo
#

You should use SELECT * FROM "Todo"; (notice the quotes).

peak flame
#

thanks!