Sebastian
Sebastian
Explore posts from servers
DTDrizzle Team
Created by Sebastian on 7/9/2023 in #help
Cannot drop index 'idx': needed in a foreign key constraint
This was the SQL code that was throwing the error: DROP INDEX user_id_idx ON user_profile;--> statement-breakpoint ALTER TABLE user_profile ADD PRIMARY KEY (user_id);--> statement-breakpoint ALTER TABLE user_profile DROP COLUMN id;--> statement-breakpoint Changing the order of the statements makes the script run successfully ALTER TABLE user_profile DROP COLUMN id;--> statement-breakpoint ALTER TABLE user_profile ADD PRIMARY KEY (user_id);--> statement-breakpoint DROP INDEX user_id_idx ON user_profile;--> statement-breakpoint
2 replies