I am just getting started using drizzle and created a simple table in a seperate schema file:
import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
export const users = pgTable('users', {
id: serial('id').primaryKey(),
email: text('email').unique(),
password: varchar('password_hash', { length: 256 }),
});
export type User = typeof users.$inferSelect
export type NewUser = typeof users.$inferInsert
After that I am trying to generate the corresponding SQL files with:
bunx drizzle-kit generate:pg --schema=src/db/schema/users.ts
I do get the output: 0 tables No schema changes, nothing to migrate
This is kinda odd because I just used the example code of the website and just tweaked the properties. I expect drizzle-kit to recognize the defined table called 'users'. Am I missing something here?
Greetings :)
I also tried to rewrite the table definition with a schema definition like this:
import { pgSchema, serial, text, varchar } from "drizzle-orm/pg-core";
export const mSchema = pgSchema("my_schema")
export const users = mSchema.table('users', {
id: serial('id').primaryKey(),
email: text('email').unique(),
password: varchar('password_hash', { length: 256 })
});
Still the same output: 0 tables No schema changes, nothing to migrate
I will also add my config file, just in case it matters:
{
"driver": "pg",
"schema": ["src/db/schema/users.ts"],
"dbCredentials": {
"connectionString": "postgres://localdev:localdev@localhost:5432/thesecondbrain"
},
"out": "./drizzle",
"verbose": true
}
Had the same issue - seems like
drizzle-kit
just doesn't work with bun at the moment. If you install npm alongside bun and specifically run the generate command with npm, it works just fine.