-- ============================================
-- WORKAROUND: If SET FOREIGN_KEY_CHECKS doesn't work
-- Try checking if the index name is different
-- ============================================

-- STEP 1: Check ALL indexes on bids table
SHOW INDEX FROM `bids`;

-- Look for any index that includes BOTH inquiryId and supplierId
-- Note the Key_name value

-- STEP 2: Try dropping with different possible names
-- Common variations:
-- ALTER TABLE `bids` DROP INDEX `bids_inquiry_id_supplier_id`;
-- ALTER TABLE `bids` DROP INDEX `bids_inquiryId_supplierId`;
-- ALTER TABLE `bids` DROP INDEX `bids_inquiryId_supplierId_unique`;
-- ALTER TABLE `bids` DROP INDEX `bids_inquiryId_supplierId_1`;

-- STEP 3: If none of the above work, try this alternative:
-- Modify the columns to remove the constraint (this might work)
SET FOREIGN_KEY_CHECKS = 0;

-- Try modifying columns (this might remove the index)
ALTER TABLE `bids` 
  MODIFY COLUMN `inquiryId` INT NOT NULL,
  MODIFY COLUMN `supplierId` INT NOT NULL;

-- Now try dropping the index again
ALTER TABLE `bids` DROP INDEX `bids_inquiry_id_supplier_id`;

SET FOREIGN_KEY_CHECKS = 1;

-- STEP 4: Recreate foreign keys if needed
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: Create non-unique index
CREATE INDEX `idx_bids_inquiry_supplier` ON `bids` (`inquiryId`, `supplierId`);

-- STEP 6: Verify
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId`);

