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) }
})
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)
})
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
);
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
);
No description
4 Replies
entropy
entropyOP3mo ago
the weird part is that I can update a column type like number from integer to number and it works fine I've already tried dropping my table, creating a new docker container on a new volume, and deleting all migrations and none of that worked
Mario564
Mario5643mo ago
What exactly is wrong? The column names? I see that certain keys don't match the assigned alias (like folderName as key but file_name as alias) (Also, hi entro!) Or are you talking about the FK not being generated?
entropy
entropyOP3mo ago
I just realized that.... thanks for catching my extremely dumb mistake tho! hey!!
Mario564
Mario5643mo ago
It do be like that. Glad you got it solved though
Want results from more Discord servers?
Add your server