[ERROR] TypeError: Cannot read properties of undefined (reading 'toString')

I keep getting this error when i run drizzle-kit push. I dont know if it has anything to do with my schema
> drizzle-kit push

drizzle-kit: v0.21.4
drizzle-orm: v0.30.10

No config path provided, using default path
Reading config file '/Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/drizzle.config.ts'
Using 'postgres' driver for database querying
[⣽] Pulling schema from database.../Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/node_modules/drizzle-kit/bin.cjs:16161
const columnDefaultAsString = column7.column_default.toString();
^

TypeError: Cannot read properties of undefined (reading 'toString')
at defaultForColumn (/Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/node_modules/drizzle-kit/bin.cjs:16161:60)
at /Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/node_modules/drizzle-kit/bin.cjs:15992:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
> drizzle-kit push

drizzle-kit: v0.21.4
drizzle-orm: v0.30.10

No config path provided, using default path
Reading config file '/Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/drizzle.config.ts'
Using 'postgres' driver for database querying
[⣽] Pulling schema from database.../Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/node_modules/drizzle-kit/bin.cjs:16161
const columnDefaultAsString = column7.column_default.toString();
^

TypeError: Cannot read properties of undefined (reading 'toString')
at defaultForColumn (/Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/node_modules/drizzle-kit/bin.cjs:16161:60)
at /Users/genio/Developer/INVE-APPS/INVE-API/kfupm-global-todo/node_modules/drizzle-kit/bin.cjs:15992:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
8 Replies
Genio
Genio4mo ago
Schema
export const Profile = createTable("profile", {
// Matches id from auth.users table in Supabase
id: uuid("id")
.primaryKey()
.references(() => Users.id, { onDelete: "cascade" }),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
createdAt: timestamp("created_at").notNull().defaultNow(),
firstName: varchar("first_name"),
lastName: varchar("last_name"),
mobileNumber: varchar("mobile_number"),
location: varchar("location"),
// gender: genderEnum('gender').default('unknown'),
// role: roleEnum('role').default('user'),
otpCode: text("otpCode"),
});


export const Events = createTable("events", {
id: uuid("id").primaryKey(),
owner: uuid("owner").references(() => Users.id),
eventName: varchar("event_name"),
eventLocation: varchar("event_location"),
eventDate: timestamp("event_date"),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
createdAt: timestamp("created_at").notNull().defaultNow(),
qrHash: varchar("qr_hash"),
qrDesignUrl: text("qr_design_url"),
cardDesignUrl: text("card_design_url"),
})


export const EventAttendees = createTable("event_attendees", {
id: uuid("id").primaryKey(),
eventId: uuid("event_id").references(() => Events.id),
name: varchar("name"),
number: varchar("number"),
status: varchar("status"),
reply: varchar("reply"),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
createdAt: timestamp("created_at").notNull().defaultNow(),
})
export const Profile = createTable("profile", {
// Matches id from auth.users table in Supabase
id: uuid("id")
.primaryKey()
.references(() => Users.id, { onDelete: "cascade" }),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
createdAt: timestamp("created_at").notNull().defaultNow(),
firstName: varchar("first_name"),
lastName: varchar("last_name"),
mobileNumber: varchar("mobile_number"),
location: varchar("location"),
// gender: genderEnum('gender').default('unknown'),
// role: roleEnum('role').default('user'),
otpCode: text("otpCode"),
});


export const Events = createTable("events", {
id: uuid("id").primaryKey(),
owner: uuid("owner").references(() => Users.id),
eventName: varchar("event_name"),
eventLocation: varchar("event_location"),
eventDate: timestamp("event_date"),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
createdAt: timestamp("created_at").notNull().defaultNow(),
qrHash: varchar("qr_hash"),
qrDesignUrl: text("qr_design_url"),
cardDesignUrl: text("card_design_url"),
})


export const EventAttendees = createTable("event_attendees", {
id: uuid("id").primaryKey(),
eventId: uuid("event_id").references(() => Events.id),
name: varchar("name"),
number: varchar("number"),
status: varchar("status"),
reply: varchar("reply"),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
createdAt: timestamp("created_at").notNull().defaultNow(),
})
@migs same issue as you apparently good catch that you found out it was the references i removed mine nad it worked however, after pushing. When i uncommented the references. I keep getting the same error
migs
migs4mo ago
Don't know if it's just with sqlite/turso but lately I've been having a lot of problems with migrations
Genio
Genio4mo ago
i found out its not documented but if you do references, you need to also define the relation take a look at this
Genio
Genio4mo ago
Genio
Genio4mo ago
No description
Genio
Genio4mo ago
Maybe this is why its causing the issue ? I am still defining the relations in my schema, will test tomorrow if it works
migs
migs4mo ago
We might have different problems, if you check my thread, I have also defined the relations with the drizzle api
Genio
Genio4mo ago
i lost ur thread, can you ping me
Want results from more Discord servers?
Add your server