X
Xata5mo ago
Storm

Does type "serial" exist in Xata/Drizzle?

I keep getting error: type "serial" does not exist when I push my schema: id: serial('id').primaryKey().notNull(), and if I do introspect I get this: id: integer("id").default(nextval('cv_theque_profiles_id_seq'::regclass)).primaryKey().notNull(), which is not valid syntaxically
No description
5 Replies
kostas
kostas5mo ago
Xata supports it, the error looks like Drizzle does not know of the type. Are you importing it from pg-core?
import { pgTable, serial } from 'drizzle-orm/pg-core';
import { pgTable, serial } from 'drizzle-orm/pg-core';
Just tested it, it correctly creates a sequence in Xata. There may be a bug in how drizzle handles it
kostas
kostas5mo ago
There's a reported drizzle bug for this: https://github.com/drizzle-team/drizzle-orm/issues/2183
GitHub
[BUG]: error: type "serial" does not exist · Issue #2183 · drizzle-...
What version of drizzle-orm are you using? 0.30.8 What version of drizzle-kit are you using? 0.20.16 Describe the Bug After generating a migration with drizzle-kit, running drizzle-kit push:pg resu...
Storm
Storm5mo ago
I have created everything from scratch again: this my drizzle schema:
import { pgTable, serial } from 'drizzle-orm/pg-core'

export const test = pgTable('test', {
id: serial('id').primaryKey().notNull(),
})
import { pgTable, serial } from 'drizzle-orm/pg-core'

export const test = pgTable('test', {
id: serial('id').primaryKey().notNull(),
})
and that's is how it reflects on Xata dashboard after pushing (image attached) and this is what I get after introspecting:
import { pgTable, integer } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"



export const test = pgTable("test", {
id: integer("id").default(nextval('test_id_seq'::regclass)).primaryKey().notNull(),
});
import { pgTable, integer } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"



export const test = pgTable("test", {
id: integer("id").default(nextval('test_id_seq'::regclass)).primaryKey().notNull(),
});
No description
kostas
kostas5mo ago
The Xata expression is correct, this is the Postgres-native syntax for Drizzle's "serial". Drizzle seems to have a bug handling this, after creating it (see the linked issue)
Storm
Storm5mo ago
I see. Thank you again for clarifying.
Want results from more Discord servers?
Add your server