Drizzle Studio fails to run due to TypeError
pnpm drizzle-kit studio
, won't launch Studio. It was working fine, but I added a few new tables and relations to my schema and it won't launch. The strangest part is generate
and migrate
run without errors.
Here is the error output:
No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/**********/WebDev/*****-********/drizzle.config.ts'
TypeError: Cannot read properties of undefined (reading 'reduce')
at one (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/relations.cjs:207:21)
at <anonymous> (/Users/**********/WebDev/*****-********/src/lib/db/schema/auth.ts:21:8)
at Relations.config (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/relations.cjs:194:22)
at extractTablesRelationalConfig (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/relations.cjs:165:32)
at prepareServer (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:64894:85)
at Object.handler (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:87579:28)
at async run (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:85613:7)
No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/**********/WebDev/*****-********/drizzle.config.ts'
TypeError: Cannot read properties of undefined (reading 'reduce')
at one (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/relations.cjs:207:21)
at <anonymous> (/Users/**********/WebDev/*****-********/src/lib/db/schema/auth.ts:21:8)
at Relations.config (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/relations.cjs:194:22)
at extractTablesRelationalConfig (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/relations.cjs:165:32)
at prepareServer (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:64894:85)
at Object.handler (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:87579:28)
at async run (/Users/**********/WebDev/*****-********/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:85613:7)
3 Replies
and here is the file that is being flagged in the error (it's the new tables added)
bump
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
import { relations } from 'drizzle-orm';
export const users = sqliteTable('users', {
id: text('id').primaryKey()
});
export const sessions = sqliteTable('sessions', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => users.id),
expiresAt: integer('expires_at').notNull()
});
export const usersRelations = relations(users, ({ many }) => ({
sessions: many(sessions)
}));
export const sessionsRelations = relations(sessions, ({ one }) => ({
user: one(users, {
field: [sessions.userId],
references: [users.id]
})
}));
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
import { relations } from 'drizzle-orm';
export const users = sqliteTable('users', {
id: text('id').primaryKey()
});
export const sessions = sqliteTable('sessions', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => users.id),
expiresAt: integer('expires_at').notNull()
});
export const usersRelations = relations(users, ({ many }) => ({
sessions: many(sessions)
}));
export const sessionsRelations = relations(sessions, ({ one }) => ({
user: one(users, {
field: [sessions.userId],
references: [users.id]
})
}));
@bobmusinex Hi! You need to replace
field
with fields
.Goodness, that was easy...
Thanks!!