Supabase primary key type
When I run
introspect
, the primary key of my tables look something like this:
Problem is this doesn't auto-increment upon insert. It seems like there's no support for integer "generated always as identity" in Drizzle which is how Supabase does things by default.
Does this mean I have to switch all my primary keys to bigserial
instead?![No description](https://cdn.answeroverflow.com/1179561262519169044/SCR-20231129-njtx.png)
4 Replies
Kind of dissapointed that drizzle doesn't support "generated always as identity" since this is recommended by postgres instead of serial. But I was able to get past this by migrating my primary keys to serial. Got the error:
or: type "serial" does not exist
but I got around it by recreating my tables in Supabase (export table data as csv and reimported which was kind of annoying).There is a PR open for this. We should get it pretty soon https://github.com/drizzle-team/drizzle-orm/pull/1471
GitHub
Feat: Drizzle-ORM support for Generated columns by Angelelz · Pull ...
This PR will close #261, will close #579 and will close #1464.
The API for generated columns will look like this:
const users = sqliteTable(
'users',
{
id: int('id').primary...
@Angelelz once this is done will there be an easy way to migrate to "generated always as identity"? When I migrated to serial, I had to recreate all tables because of the
"serial" does not exist
errorI think that if you move to serial you have issues, but not the way around. I'm honestly not sure