Wierd error when trying to run drizzle studio

I want to start with saying sorry if the problem is obvious but I cannot seem to figure it out. I am getting a wierd error when I try to run drizzle studio.
drizzle-kit: v0.20.6
drizzle-orm: v0.29.1
drizzle-kit: v0.20.6
drizzle-orm: v0.29.1
here are my package.json scripts that are relevant:
"studio": "drizzle-kit studio --port 5666 --verbose --config ./db/drizzle.config.ts "
"studio": "drizzle-kit studio --port 5666 --verbose --config ./db/drizzle.config.ts "
drizzle.config.ts is:
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config();
import { dbUrl } from "./config";

export default {
schema: "./db/schema/*",
out: "./drizzle",
driver: 'pg',
dbCredentials: {
connectionString: dbUrl,
}
} satisfies Config;
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config();
import { dbUrl } from "./config";

export default {
schema: "./db/schema/*",
out: "./drizzle",
driver: 'pg',
dbCredentials: {
connectionString: dbUrl,
}
} satisfies Config;
3 Replies
The cultured one
The cultured oneOP12mo ago
Here is the error i get when i run studio
❯ yarn run studio
yarn run v1.22.21
$ drizzle-kit studio --port 5666 --verbose --config ./db/drizzle.config.ts
drizzle-kit: v0.20.6
drizzle-orm: v0.29.1

Custom config path was provided, using './db/drizzle.config.ts'
Reading config file '/home/mugur/Work/bookd/packages/bookd-api/db/drizzle.config.ts'
/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:47
this.referencedTableName = referencedTable[import_table.Table.Symbol.Name];
^

TypeError: Cannot read properties of undefined (reading 'Symbol(drizzle:Name)')
at new Relation (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:47:47)
at new Many (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:80:5)
at many (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:213:12)
at <anonymous> (/home/mugur/Work/bookd/packages/bookd-api/db/schema/booking.ts:47:15)
at Relations.config (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:194:22)
at extractTablesRelationalConfig (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:165:32)
at relationsToTypeScript (/home/mugur/Work/bookd/node_modules/drizzle-kit/bin.cjs:19022:82)
at Command.<anonymous> (/home/mugur/Work/bookd/node_modules/drizzle-kit/bin.cjs:63620:25)

Node.js v18.14.2
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
❯ yarn run studio
yarn run v1.22.21
$ drizzle-kit studio --port 5666 --verbose --config ./db/drizzle.config.ts
drizzle-kit: v0.20.6
drizzle-orm: v0.29.1

Custom config path was provided, using './db/drizzle.config.ts'
Reading config file '/home/mugur/Work/bookd/packages/bookd-api/db/drizzle.config.ts'
/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:47
this.referencedTableName = referencedTable[import_table.Table.Symbol.Name];
^

TypeError: Cannot read properties of undefined (reading 'Symbol(drizzle:Name)')
at new Relation (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:47:47)
at new Many (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:80:5)
at many (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:213:12)
at <anonymous> (/home/mugur/Work/bookd/packages/bookd-api/db/schema/booking.ts:47:15)
at Relations.config (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:194:22)
at extractTablesRelationalConfig (/home/mugur/Work/bookd/node_modules/drizzle-orm/relations.cjs:165:32)
at relationsToTypeScript (/home/mugur/Work/bookd/node_modules/drizzle-kit/bin.cjs:19022:82)
at Command.<anonymous> (/home/mugur/Work/bookd/node_modules/drizzle-kit/bin.cjs:63620:25)

Node.js v18.14.2
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Let me know If there is any more information I can provide regarding this. The folder structure for schema is /db/schema/[entity].ts and /db/schema/index.ts which looks like this:
export * from "./aditional-service"
export * from "./booking-snapshot"
export * from "./booking"
export * from "./client"
export * from "./discount"
export * from "./membership-type"
export * from "./membership"
export * from "./pet-on-booking"
export * from "./pet"
export * from "./price"
export * from "./room-type"
export * from "./room"
export * from "./status"
export * from "./task"
export * from "./user"
export * from './booking-on-room'
export * from './aditional-service-on-booking'
export * from './pet-on-booking'
export * from "./aditional-service"
export * from "./booking-snapshot"
export * from "./booking"
export * from "./client"
export * from "./discount"
export * from "./membership-type"
export * from "./membership"
export * from "./pet-on-booking"
export * from "./pet"
export * from "./price"
export * from "./room-type"
export * from "./room"
export * from "./status"
export * from "./task"
export * from "./user"
export * from './booking-on-room'
export * from './aditional-service-on-booking'
export * from './pet-on-booking'
The entities themselves export some more stuff, for example(booking.ts):
import { integer, pgTable, timestamp, varchar } from 'drizzle-orm/pg-core';
import { BrandedID, buildIsValidFunc, prefixedUlid } from '../utils';
import { z } from 'zod';
import { relations } from 'drizzle-orm';
import { client, clientID } from './client';
import { petOnBooking } from './pet-on-booking';
import { status, statusID } from './status';
import { bookingSnapshot } from './booking-snapshot';
import { bookingOnRoom } from './booking-on-room';
import { aditionalServiceOnBooking } from './aditional-service-on-booking';



export const bookingPrefix = 'bk'


export type bookingID = BrandedID<'bookingID'>


export const isBookingID = buildIsValidFunc<bookingID>(bookingPrefix)

export const zBookingID = z.custom<bookingID>().refine((value) => isBookingID(value))

export const booking = pgTable('booking', {
id: prefixedUlid(bookingPrefix).$type<bookingID>(),
startDate: timestamp('startDate').notNull(),
endDate: timestamp('endDate').notNull(),
totalPrice: integer('totalPrice').notNull(),
avalailableDays: integer('availableDays').notNull(),

note: varchar('note'),


// totalPrice: computed
clientId: varchar('clientId').$type<clientID>().notNull().references(() => client.id),
statusId: varchar('statusId').$type<statusID>().notNull().references(() => status.id),

createdAt: timestamp('createdAt').defaultNow().notNull(),
updatedAt: timestamp('updatedAt').defaultNow().notNull()
});

export const bookingRelations = relations(booking, ({ one, many }) => ({
client: one(client, {
fields: [booking.clientId],
references: [client.id],
}),
petInRooms: many(petOnBooking),
rooms: many(bookingOnRoom),
status: one(status, {
fields: [booking.statusId],
references: [status.id]
}),
aditionalServices: many(aditionalServiceOnBooking),
bookingSnapshots: many(bookingSnapshot)
}))
import { integer, pgTable, timestamp, varchar } from 'drizzle-orm/pg-core';
import { BrandedID, buildIsValidFunc, prefixedUlid } from '../utils';
import { z } from 'zod';
import { relations } from 'drizzle-orm';
import { client, clientID } from './client';
import { petOnBooking } from './pet-on-booking';
import { status, statusID } from './status';
import { bookingSnapshot } from './booking-snapshot';
import { bookingOnRoom } from './booking-on-room';
import { aditionalServiceOnBooking } from './aditional-service-on-booking';



export const bookingPrefix = 'bk'


export type bookingID = BrandedID<'bookingID'>


export const isBookingID = buildIsValidFunc<bookingID>(bookingPrefix)

export const zBookingID = z.custom<bookingID>().refine((value) => isBookingID(value))

export const booking = pgTable('booking', {
id: prefixedUlid(bookingPrefix).$type<bookingID>(),
startDate: timestamp('startDate').notNull(),
endDate: timestamp('endDate').notNull(),
totalPrice: integer('totalPrice').notNull(),
avalailableDays: integer('availableDays').notNull(),

note: varchar('note'),


// totalPrice: computed
clientId: varchar('clientId').$type<clientID>().notNull().references(() => client.id),
statusId: varchar('statusId').$type<statusID>().notNull().references(() => status.id),

createdAt: timestamp('createdAt').defaultNow().notNull(),
updatedAt: timestamp('updatedAt').defaultNow().notNull()
});

export const bookingRelations = relations(booking, ({ one, many }) => ({
client: one(client, {
fields: [booking.clientId],
references: [client.id],
}),
petInRooms: many(petOnBooking),
rooms: many(bookingOnRoom),
status: one(status, {
fields: [booking.statusId],
references: [status.id]
}),
aditionalServices: many(aditionalServiceOnBooking),
bookingSnapshots: many(bookingSnapshot)
}))
It seems a typo in the schema caused this. This issue can be closed. Sorry for bothering you for a typo!!!
doogilie
doogilie11mo ago
im getting this error too 😭 what was your typo? @The cultured one nvm i got it, i had to change my imports to point to the source instead of an index.ts middleman for some reason
The cultured one
The cultured oneOP11mo ago
Sorry, I didn't notice the comment until now. I honestly can't remember but it was something small and stupid xD. Good for you!
Want results from more Discord servers?
Add your server