Drizzle Studio: Cannot read properties of undefined (reading 'name')

hey drizzle team, been trying to migrate from prisma to drizzle, but I can't seem to get the studio working. after running npx drizzle-kit studio, i get error you see in the image. here's my schema.ts, which is inside drizzle/schema/schema.ts
export const user = pgTable('user', {
id: uuid('id').primaryKey(),
profileId: serial('profile_id').references(() => profile.id),
});

export const profile = pgTable('profile', {
id: serial('id').primaryKey(),
email: text('email').unique(),
name: text('name'),
gender: genderEnum('gender'),
dob: timestamp('dob', { precision: 6, withTimezone: true }),
updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }).$onUpdate(
() => new Date(),
),
});
export const user = pgTable('user', {
id: uuid('id').primaryKey(),
profileId: serial('profile_id').references(() => profile.id),
});

export const profile = pgTable('profile', {
id: serial('id').primaryKey(),
email: text('email').unique(),
name: text('name'),
gender: genderEnum('gender'),
dob: timestamp('dob', { precision: 6, withTimezone: true }),
updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }).$onUpdate(
() => new Date(),
),
});
drizzle.config.ts
import type { Config } from 'drizzle-kit';
const DATABASE_URL = process.env.DATABASE_URL;
if (!DATABASE_URL) {
throw new Error('DATABASE_URL is not set');
}
export default {
schema: ['./drizzle/schema/*.ts'],
out: './drizzle',
driver: 'pg',
dbCredentials: {
connectionString: DATABASE_URL,
},
verbose: true,
strict: true,
} satisfies Config;
import type { Config } from 'drizzle-kit';
const DATABASE_URL = process.env.DATABASE_URL;
if (!DATABASE_URL) {
throw new Error('DATABASE_URL is not set');
}
export default {
schema: ['./drizzle/schema/*.ts'],
out: './drizzle',
driver: 'pg',
dbCredentials: {
connectionString: DATABASE_URL,
},
verbose: true,
strict: true,
} satisfies Config;
even after clearing out my schema.ts, resetting my local supabase db, i still get the same error. was wondering if anyone has faced the same issue or could share how they manage to resolve this? thanks!
No description
3 Replies
⚡Z.E.U.S⚡
⚡Z.E.U.S⚡8mo ago
@XenoWaiT Hey! Can you please share genderEnum too? Is it in some other file?
XenoWaiT
XenoWaiTOP8mo ago
@Ze'ev sure its imported from a file enums.ts
export enum Gender {
MALE = "MALE",
FEMALE = "FEMALE",
}


export function enumToPgEnum(myEnum: any): [string, ...string[]] {
return Object.values(myEnum).map((value: any) => `${value}`) as [
string,
...string[],
];
}
const genderEnumList = enumToPgEnum(Gender);
export const genderEnum = pgEnum('gender', genderEnumList);
export enum Gender {
MALE = "MALE",
FEMALE = "FEMALE",
}


export function enumToPgEnum(myEnum: any): [string, ...string[]] {
return Object.values(myEnum).map((value: any) => `${value}`) as [
string,
...string[],
];
}
const genderEnumList = enumToPgEnum(Gender);
export const genderEnum = pgEnum('gender', genderEnumList);
⚡Z.E.U.S⚡
⚡Z.E.U.S⚡8mo ago
@XenoWaiT Hey! Can you try updating drizzle-kit to latest version?
Want results from more Discord servers?
Add your server