How to drop a failed drizzle-kit push?

Hi, I made some changes to table (transformed some bigint("id", { mode: "number" }).notNull() to bigint("id", { mode: "number" }).primaryKey()). I tried to apply my changes with bun run dotenv drizzle-kit push:mysql as usual... And I got some errors:
Error: target: snacs.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'id' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: q7b5b4s79a6trurkk7ej): Sql: "alter table snacs_food_attribute drop check id", BindVars: {REDACTED}
at PromiseConnection.query (/home/lelabo/DEV/SNACS/willitfodmap/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/lelabo/DEV/SNACS/willitfodmap/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: undefined,
errno: 3821,
sql: 'ALTER TABLE `snacs_food_attribute` DROP CONSTRAINT `id`;',
sqlState: 'HY000',
sqlMessage: `target: snacs.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'id' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: q7b5b4s79a6trurkk7ej): Sql: "alter table snacs_food_attribute drop check id", BindVars: {REDACTED}`
}
Error: target: snacs.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'id' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: q7b5b4s79a6trurkk7ej): Sql: "alter table snacs_food_attribute drop check id", BindVars: {REDACTED}
at PromiseConnection.query (/home/lelabo/DEV/SNACS/willitfodmap/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/lelabo/DEV/SNACS/willitfodmap/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: undefined,
errno: 3821,
sql: 'ALTER TABLE `snacs_food_attribute` DROP CONSTRAINT `id`;',
sqlState: 'HY000',
sqlMessage: `target: snacs.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'id' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: q7b5b4s79a6trurkk7ej): Sql: "alter table snacs_food_attribute drop check id", BindVars: {REDACTED}`
}
So, I revert the changes, and try again to push some very minor change to another table to check if everything is ok. And I still get the same error. I don't know how I am supposed to drop the current cached mutation.
1 Reply
lelabo
lelaboOP11mo ago
For more context: I am working with PlanetScale and always used dotenv drizzle-kit push:mysql to apply changes in the past. I read the documentation about the others command and try drop for example, but it seems I need to have an migration folder locally (I don't understand in my case where are the migration information stored). I did not try generate and introspect yet, in fear of f***ing everything up. I did not find information on how the two workflows are compatible/switchable. Did not understand really what happened BUT: I runned bun drizzle-kit introspect:mysql to download the DDL. I tried to bun drizzle-kit generate:mysql with this schema and I could see the changes it wanted to make. And from there I could see that it wanted to do some strange alter statements. Not wanting to deal with this on a dev branch, I just deleted my tables.
Want results from more Discord servers?
Add your server