Replies: 1 comment
-
Hello! We are using The columns are created with something like: Schema looks like this: Since it's done at the db level the data is guaranteed consistent, you don't have to manually calculate the value when retrieving data and you can use it like any column i.e. order by without using They use So using If I run But this is not the same as the above as it will only set the value once. |
Beta Was this translation helpful? Give feedback.
-
A long time ago, Prisma used the
@default
value/functiondbgenerated()
to represent default values that could not be expressed in@default
directly.Later we added a string parameter to the
dbgenerated()
function, so you can now actually define whatever should be put into theDEFAULT
value in the generated migration. We also updated Prisma's Introspection to use@default(dbgenerated("..."))
when encountering default values that do not fit into@default
directly.Since then
dbgenerated()
is technically not necessary any more in Prisma.We are now thinking about removing
dbgenerated()
as a valid value of@default
and make it a Schema validation error instead in a future version of Prisma. Of course, we do not want to cause unneeded work and trouble for users that currently still havedbgenerated()
in their Prisma schema, and hence are asking you for feedback if your project is currently still usingdbgenerated()
:prisma db pull
) create a schema with@default(dbgenerated())
for your database? If so, please answer with the relevant snippet of your Prisma schema and also the underlying database SQL schema. Does it still happen with recent Prisma versions (4.16.2 and up)?dbgenerated()
manually? If so, please answer with why you chose to not define the actual default value for the field or usedbgenerated
with a string parameter. Does Prisma Introspection (prisma db pull
) overwrite the emptydbgenerated()
with a more useful value for you? Can you cleanly run migrations afterwards?dbgenerated()
for some other reason? Please comment and explain below.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions