generate:pg generates 0 tables despite all settings being correct.

When I run bun --bun drizzle-kit generate:pg I get the following:
drizzle-kit: v0.20.14
drizzle-orm: v0.29.3
No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/mirage/workspace/labs/casa/fe-casa/drizzle.config.ts'
0 tables
No schema changes, nothing to migrate :sleeping:
drizzle-kit: v0.20.14
drizzle-orm: v0.29.3
No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/mirage/workspace/labs/casa/fe-casa/drizzle.config.ts'
0 tables
No schema changes, nothing to migrate :sleeping:
When I run bun run src/lib/server/migrate.ts, I get:
[Function: sql]
{
severity_local: "NOTICE",
severity: "NOTICE",
code: "42P06",
message: "schema \"drizzle\" already exists, skipping",
file: "schemacmds.c",
line: "135",
routine: "CreateSchemaCommand",
}
{
severity_local: "NOTICE",
severity: "NOTICE",
code: "42P07",
message: "relation \"__drizzle_migrations\" already exists, skipping",
file: "parse_utilcmd.c",
line: "210",
routine: "transformCreateStmt",
}
[Function: sql]
{
severity_local: "NOTICE",
severity: "NOTICE",
code: "42P06",
message: "schema \"drizzle\" already exists, skipping",
file: "schemacmds.c",
line: "135",
routine: "CreateSchemaCommand",
}
{
severity_local: "NOTICE",
severity: "NOTICE",
code: "42P07",
message: "relation \"__drizzle_migrations\" already exists, skipping",
file: "parse_utilcmd.c",
line: "210",
routine: "transformCreateStmt",
}
Schema:
import { relations } from "drizzle-orm";
import { serial, text, pgTable, timestamp, integer, varchar, uuid } from "drizzle-orm/pg-core";

export const user = pgTable('user', {
uuid: uuid('uuid').defaultRandom().primaryKey(),
name: text('name'),
email: text('email').notNull(),
surname: text('surname'),
password: text('password'),
role: text('role').$type<'admin' | 'user'>(),
createdAt: timestamp('created_at'),
updatedAt: timestamp('updated_at'),
});

export const event = pgTable('event', {
id: serial('id').primaryKey(),
name: text('name'),
category: text('email').notNull(),
description: varchar('description', { length: 256 }),
createdAt: timestamp('created_at'),
updatedAt: timestamp('updated_at'),
user_id: integer('user_id')
});

export const userRelations = relations(user, ({ many }) => ({
event: many(event)
}));

export const eventRelations = relations(event, ({ one }) => ({
user: one(user, {
fields: [event.user_id],
references: [user.uuid]
})
}));
import { relations } from "drizzle-orm";
import { serial, text, pgTable, timestamp, integer, varchar, uuid } from "drizzle-orm/pg-core";

export const user = pgTable('user', {
uuid: uuid('uuid').defaultRandom().primaryKey(),
name: text('name'),
email: text('email').notNull(),
surname: text('surname'),
password: text('password'),
role: text('role').$type<'admin' | 'user'>(),
createdAt: timestamp('created_at'),
updatedAt: timestamp('updated_at'),
});

export const event = pgTable('event', {
id: serial('id').primaryKey(),
name: text('name'),
category: text('email').notNull(),
description: varchar('description', { length: 256 }),
createdAt: timestamp('created_at'),
updatedAt: timestamp('updated_at'),
user_id: integer('user_id')
});

export const userRelations = relations(user, ({ many }) => ({
event: many(event)
}));

export const eventRelations = relations(event, ({ one }) => ({
user: one(user, {
fields: [event.user_id],
references: [user.uuid]
})
}));
Can anyone help? What am I missing? I'm trying to get drizzle setup, and I've been stuck in this for almost a day now. Any help would be appreciated.
2 Replies
Mykhailo
Mykhailo10mo ago
Hello, @ashwinr! Could you try to run bunx drizzle-kit generate:pg instead of bun --bun drizzle-kit generate:pg? bunx solved the issue for me
ashwinr
ashwinrOP10mo ago
@solo Thank you very much. That worked.
Want results from more Discord servers?
Add your server