-- Drop the foreign key constraint first
ALTER TABLE `budgets` DROP FOREIGN KEY `budgets_ibfk_1`;

-- Now, drop the old unique key and add the new one
ALTER TABLE `budgets`
DROP KEY `user_category_month`,
ADD UNIQUE KEY `client_month_category` (`client_id`, `budget_month`, `category`);

-- Add the foreign key back
ALTER TABLE `budgets` ADD CONSTRAINT `fk_budgets_user_id` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;