-- Direct approach: Find foreign key, drop it, then drop unique index
-- Based on your table, the unique index is: bids_inquiry_id_supplier_id

-- STEP 1: Find foreign key constraint names
-- Run this query:
SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids';

-- OR try this alternative:
SELECT CONSTRAINT_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids'
  AND REFERENCED_TABLE_NAME IS NOT NULL;

-- STEP 2: Drop the foreign key(s) - use the CONSTRAINT_NAME from Step 1
-- Common names might be:
-- ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_1`;
-- ALTER TABLE `bids` DROP FOREIGN KEY `bids_ibfk_2`;
-- Or whatever name appears in Step 1

-- STEP 3: Drop the unique index (this should work after dropping FK)
ALTER TABLE `bids` DROP INDEX `bids_inquiry_id_supplier_id`;

-- STEP 4: 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;

-- STEP 5: Verify - should only see Non_unique = 1
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId');

