How to set a default value for column based on another column?
For example, if I had this schema:
How could I make the
slug
column's default be determined based on title
via a slugify function?11 Replies
I'm not sure in sqlite but in Mysql there are generated columns that can do that for you
Those are currently not supported in Drizzle, but you could use custom types to make it work
I have to use SQLite, I'm using Cloudflare D1
I have the following generated column in my codebase:
And I use it like this:
Now you should take away the invisible because for us this was just for searching at db level
That should point you in the right direction
That doesn't quite seem to work though. The generated sql looks like
note the extra
""
quotes. Is there a way to unquote it?I think it's an issue with drizzle kit..gotta wait for the fix. But really gotta wait for official generated columns support
I got this notice when trying with
drizzle-kit push
then postgres throws error ahh turns out same as this issue
maybe patching here is a temp solution for it
or the
isPgNativeType
function@kane were you able to find a fix for it?
no need to patch it haha there's official support
https://discord.com/channels/1043890932593987624/1235937884956000377/1255865234418045039
š