TypeError: Cannot read properties of undefined (reading 'type') on drizzle kit push command

Can't run drizzle push:mysql on planetscale database, I'm getting this weird error:
+ Auditors table will be created
+ Integrators table will be created
+ IntegratorSelections table will be created
+ IntegratorTag table will be created
+ UserEmailVerifications table will be created
+ Users table will be created
--- all table conflicts resolved ---

/Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60388
if (unsquashed.columns.length === 1 && currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type === "serial" && prevSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type === "serial" && currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].name === unsquashed.columns[0]) {
^

TypeError: Cannot read properties of undefined (reading 'type')
at /Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60388:119
at Array.filter (<anonymous>)
at filterStatements (/Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60368:21)
at Command.<anonymous> (/Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60979:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
+ Auditors table will be created
+ Integrators table will be created
+ IntegratorSelections table will be created
+ IntegratorTag table will be created
+ UserEmailVerifications table will be created
+ Users table will be created
--- all table conflicts resolved ---

/Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60388
if (unsquashed.columns.length === 1 && currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type === "serial" && prevSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type === "serial" && currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].name === unsquashed.columns[0]) {
^

TypeError: Cannot read properties of undefined (reading 'type')
at /Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60388:119
at Array.filter (<anonymous>)
at filterStatements (/Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60368:21)
at Command.<anonymous> (/Users/*/Work/Trustblock/Dev/monorepo/node_modules/drizzle-kit/bin.cjs:60979:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The error is caused by this part: currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type
3 Replies
andrew
andrew12mo ago
did you resolve this? geting this error too..
skuse
skuse11mo ago
I get this error using planetscale DB and changing the primary key. Fixed by incrementally pushing: 1. add the ID field back to the table, push, should be successful 2. change the type of the ID field to varchar / something other than serial or primaryKey. Add the new primary key field, in my case its a compound key. Push 3. Delete the ID field and push again seems to be a bug with changing the primary key. Some kind of name conflict TLDR This bug happens when you change your primary key. To fix you need to re add the name of the field you deleted to your table, but not as serial or primary key. Once you push your changes you can delete the old field and push again.
PapaFinn
PapaFinn10mo ago
Had the same issue, but with an index. Same error and same workaround though. Had to change the index to a regular index from a unique one and then I could delete it with a separate push.
Want results from more Discord servers?
Add your server