Drizzle kit push and migrate don't match typescript schema

Hello, I'm having issues with both push and migrate commands with drizzle kit generating incorrect SQL based on my typescipt schema. Any help would be much appreciated!

drizzle.config.ts
import { defineConfig } from 'drizzle-kit'

export default defineConfig({
  dialect: 'postgresql',
  schema: './src/db/schema.ts',
  out: './src/db/migrations',
  dbCredentials: { url: String(process.env.DATABASE_URL) }
})


src/db/schema.ts
import { integer, numeric, pgTable, text } from 'drizzle-orm/pg-core'

export const chaptersTable = pgTable('chapters', {
  id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
  title: text('name').notNull(),
  number: numeric('number').notNull(),
  folderName: text('file_name').notNull(),
  mangaId: integer('manga_id')
    .notNull()
    .references(() => mangaTable.id)
})


resulting SQL
CREATE TABLE IF NOT EXISTS "chapters" (
  "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "chapters_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
  "name" text NOT NULL,
  "number" numeric NOT NULL,
  "file_name" text NOT NULL,
  "manga_id" integer NOT NULL
);
image.png
Was this page helpful?