Open rajatbarman opened 1 year ago
@rajatbarman That is actually super helpful! Thanks a lot for this case. Will handle this part while migration generation and suggest better options that will work Will change docs as well
I was just caught out by this myself.
What version of
drizzle-orm
are you using?0.23.2
Describe the Bug
package.json
Given the schema -
drizzle-kit
generateswhere the query for adding foreign key constraint fails for the reason of incompatible types as
users.id
is actuallyserial
andtokens.user_id
isint
.Now the way that this works is if I do the following in my schema -
where I replace
serial()
withint().autoincrement().notNull()
and the documentation for drizzle-orm illustrates the use of foreign key in this way -
which doesn't work.
So I believe you can figure this out by 1) Changing illustration in documentation 2) Promote (in documentation) using bigint().autoincrement().notNull() for ids as they can easily be related by a foreign key.
I can't really think of a programmatic solution for this for you guys, but maybe there is something you can do while generating SQL.