-- ============================================
-- TRY COMMON FOREIGN KEY CONSTRAINT NAMES
-- If you can't find the constraint names, try these
-- ============================================

-- Common foreign key constraint names MySQL/Sequelize uses:
-- bids_ibfk_1, bids_ibfk_2, bids_inquiryId_fk, bids_supplierId_fk

-- Try dropping these one by one (uncomment and run each):
-- If you get "Unknown key" error, that's fine - try the next one

-- Option 1:
ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_1`;

-- Option 2:
ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_2`;

-- Option 3:
ALTER TABLE `bids` DROP FOREIGN KEY `bids_inquiryId_fk`;

-- Option 4:
ALTER TABLE `bids` DROP FOREIGN KEY `bids_supplierId_fk`;

-- After successfully dropping the foreign keys, then drop the unique index:
ALTER TABLE `bids` DROP INDEX `bids_inquiry_id_supplier_id`;

-- Then recreate foreign keys:
ALTER TABLE `bids` 
  ADD CONSTRAINT `bids_inquiryId_fk` FOREIGN KEY (`inquiryId`) REFERENCES `inquiries` (`id`) ON DELETE CASCADE;

ALTER TABLE `bids` 
  ADD CONSTRAINT `bids_supplierId_fk` FOREIGN KEY (`supplierId`) REFERENCES `suppliers` (`id`) ON DELETE CASCADE;

-- Create non-unique index:
CREATE INDEX `idx_bids_inquiry_supplier` ON `bids` (`inquiryId`, `supplierId`);

