-- Final solution: Drop foreign keys and unique index
-- Run these commands one by one until one works

-- STEP 1: Try to drop common foreign key constraint names
-- Run these one at a time until one works (ignore errors if constraint doesn't exist):

ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_1`;
ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_2`;
ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_3`;
ALTER TABLE `bids` DROP FOREIGN KEY `bids_inquiryId_fk`;
ALTER TABLE `bids` DROP FOREIGN KEY `bids_supplierId_fk`;

-- STEP 2: Try to drop the unique index with different common names
-- Run these one at a time until one works:

ALTER TABLE `bids` DROP INDEX `bids_inquiry_id_supplier_id`;
ALTER TABLE `bids` DROP INDEX `bids_inquiryId_supplierId`;
ALTER TABLE `bids` DROP INDEX `inquiryId_supplierId`;
ALTER TABLE `bids` DROP INDEX `bids_inquiryId_supplierId_unique`;

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

-- STEP 4: Recreate foreign keys (for referential integrity)
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;

-- STEP 5: Verify
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId');
-- Should show Non_unique = 1 (allows duplicates)

