drizzle-team / drizzle-team/drizzle-orm
[BUG]: Invalid schema default value generated for sequence-based primary keys in Postgres
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-beta.15-859cf75
### What version of `drizzle-kit` are you using?
1.0.0-beta.15-859cf75
### Other packages
_No response_
### Describe the Bug
I am attempting to set up drizzle with the schema from the Musicbrainz database. For reproduction purposes, this schema can be recreated by running [`mbslave`](https://github.com/acoustid/mbslave) with the command `mbslave init --create-user --create-database --empty`.
When pulling the schema from this database using `drizzle-kit pull`, I get a `schema.ts` with invalid syntax for default values. I've included the output for the first table below, but the output for all other tables is very similar:
```ts
export const alternativeMediumInMusicbrainz = musicbrainz.table("alternative_medium", {
id: integer().default(nextval('alternative_medium_id_seq'::regclass)).notNull(),
medium: integer().notNull(),
alternativeRelease: integer("alternative_release").notNull(),
name: varchar(),
}, (table) => [
check("alternative_medium_name_check", sql`((name)::text <> ''::text)`),]);
```
The desired result is that the `schema.ts` file is valid Typescript. In this case, I think omitting the default value altogether would be the best approach.
Contributor guide
Assessment
This issue has not been assessed yet.