-- Fix Database Engine Mismatch causing FK Error
-- The alerts table uses MyISAM which doesn't support Foreign Keys properly
-- The investigations table (InnoDB) tries to reference it, causing errors.

-- 1. Convert alerts table to InnoDB
ALTER TABLE `alerts` ENGINE=InnoDB;

-- 2. Ensure Schema Fixes (just in case)
ALTER TABLE `users` ADD COLUMN `subscription_plan` varchar(50) DEFAULT 'free';
ALTER TABLE `users` ADD COLUMN `alerts_this_month` int(11) DEFAULT 0;
ALTER TABLE `users` ADD COLUMN `last_usage_reset` datetime DEFAULT current_timestamp();
