planetscale - removing uniqueIndex
Hey there, I'm trying to remove a unique index on planetscale but when I push my schema, it tells me the constraint is not found
My change:
(table) => ({
tenantIdIdx: uniqueIndex("tenant_id_idx").on(table.tenantId),
- slugIdx: uniqueIndex("slug_idx").on(table.slug),
}),
(table) => ({
tenantIdIdx: uniqueIndex("tenant_id_idx").on(table.tenantId),
- slugIdx: uniqueIndex("slug_idx").on(table.slug),
}),
pnpm drizzle-kit push:mysql
pnpm drizzle-kit push:mysql
3 Replies
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6
No config path provided, using default path
Reading config file '/Users/andreasthomas/github/unkeyed/unkey/internal/db/drizzle.config.ts'
Reading schema files:
/Users/andreasthomas/github/unkeyed/unkey/internal/db/src/schema/index.ts
· You're about to add slug_idx_renamed unique constraint to the table, which contains 23348 items. If this statement fails, you will receive an error from the database. Do you want to truncate workspaces table?
Warning Found data-loss statements:
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED
Do you still want to push changes?
Error: target: unkey.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'slug_idx' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: z25a6cdkc1d5djow5b4u): Sql: "alter table workspaces drop check slug_idx", BindVars: {REDACTED}
at PromiseConnection.query (/Users/andreasthomas/github/unkeyed/unkey/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/Users/andreasthomas/github/unkeyed/unkey/node_modules/.pnpm/[email protected]/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 `workspaces` DROP CONSTRAINT `slug_idx`;',
sqlState: 'HY000',
sqlMessage: `target: unkey.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'slug_idx' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: z25a6cdkc1d5djow5b4u): Sql: "alter table workspaces drop check slug_idx", BindVars: {REDACTED}`
}
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6
No config path provided, using default path
Reading config file '/Users/andreasthomas/github/unkeyed/unkey/internal/db/drizzle.config.ts'
Reading schema files:
/Users/andreasthomas/github/unkeyed/unkey/internal/db/src/schema/index.ts
· You're about to add slug_idx_renamed unique constraint to the table, which contains 23348 items. If this statement fails, you will receive an error from the database. Do you want to truncate workspaces table?
Warning Found data-loss statements:
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED
Do you still want to push changes?
Error: target: unkey.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'slug_idx' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: z25a6cdkc1d5djow5b4u): Sql: "alter table workspaces drop check slug_idx", BindVars: {REDACTED}
at PromiseConnection.query (/Users/andreasthomas/github/unkeyed/unkey/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/Users/andreasthomas/github/unkeyed/unkey/node_modules/.pnpm/[email protected]/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 `workspaces` DROP CONSTRAINT `slug_idx`;',
sqlState: 'HY000',
sqlMessage: `target: unkey.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'slug_idx' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: z25a6cdkc1d5djow5b4u): Sql: "alter table workspaces drop check slug_idx", BindVars: {REDACTED}`
}
according to planetscale, it exists in my schema :/
checking this one, sorry for late response
Is it still an issue?
would be also great if you can add
verbose: true
-> to print all statements to be executed
strict: true
-> to always approve any actions from push command
to your drizzle.config