error: cannot use column reference in DEFAULT expression
in this schema:
I am trying to add unitLength, but it's throwing this error when I have a default value, I get the same error with an integer.
6 Replies
Hey @Ani
the problem is that you are using serial instead of integer.
Serial is an auto-incrementing data type which is mainly useful for pk as id because it increases by 1 every time you add a record in the table.
For your use case as per I can understand, you need an integer for the length which can also have a default value of 0.
nope, same problem with an integer
createTable
where does it come from? Drizzle Studio?
Here a version with pgTable
and unitLength
as integer
:
https://drizzle.run/f5hqvbt6li92pq1hi4xpiz0jcreate table comes from the multi project schemas:
https://orm.drizzle.team/docs/goodies#multi-project-schema
___
i've tried ripping it out and just using pgTable, still getting the same error
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Have you pushed the schema to db earlier with serial data type?
If yes, then it may be the reason that it's not allowing to change it now
nope I originally did it with integer, this error is not happening on every integer with a default in my schema