mrnicericee
mrnicericee
Explore posts from servers
DTDrizzle Team
Created by mrnicericee on 9/18/2023 in #help
Dropping mysql unique errors
Hello! I saw there were already an issue created for it https://github.com/drizzle-team/drizzle-orm/issues/998 database: mysql package: drizzle-kit my own error message
errno: 3821,
sql: 'ALTER TABLE `cerberus_auth_user` DROP CONSTRAINT `cerberus_auth_user_username_unique`;',
sqlState: 'HY000',
sqlMessage: `target: personal.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'cerberus_auth_user_username_unique' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: 1t4od6gbcxmj1mldqj6f): Sql: "alter table cerberus_auth_user drop check cerberus_auth_user_username_unique", BindVars: {REDACTED}`
errno: 3821,
sql: 'ALTER TABLE `cerberus_auth_user` DROP CONSTRAINT `cerberus_auth_user_username_unique`;',
sqlState: 'HY000',
sqlMessage: `target: personal.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'cerberus_auth_user_username_unique' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: 1t4od6gbcxmj1mldqj6f): Sql: "alter table cerberus_auth_user drop check cerberus_auth_user_username_unique", BindVars: {REDACTED}`
I realized that the SQL query for dropping a UNIQUE the CONSTRAINT should be changed to INDEX
ALTER TABLE `[table here]` DROP INDEX `[constraint name]`
ALTER TABLE `[table here]` DROP INDEX `[constraint name]`
I ran the the above query in planetscale's console, and it successfully dropped the UNIQUE CONSTRAINT and then ran db:push and it successfully made the changes 🙂 I tried looking (but i am dumb) to see where the query for the drizzle-kit DROP statement would be built but I could not find anything 😦 would love to make a PR on this if possible 🙂
2 replies