-- Complete solution: Find and drop unique constraint
-- Follow these steps:

-- STEP 1: Find foreign key constraint names
-- Run this and note the CONSTRAINT_NAME values:
SELECT CONSTRAINT_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids'
  AND COLUMN_NAME IN ('inquiryId', 'supplierId')
  AND REFERENCED_TABLE_NAME IS NOT NULL;

-- STEP 2: Find the unique index name
-- Run this and note the Key_name where Non_unique = 0:
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId');

-- STEP 3: Drop foreign keys (use actual names from Step 1)
-- Replace 'FK_NAME_1' and 'FK_NAME_2' with actual constraint names
-- ALTER TABLE `bids` DROP FOREIGN KEY `FK_NAME_1`;
-- ALTER TABLE `bids` DROP FOREIGN KEY `FK_NAME_2`;

-- STEP 4: Drop unique index (use name from Step 2)
-- Replace 'INDEX_NAME' with actual Key_name
-- ALTER TABLE `bids` DROP INDEX `INDEX_NAME`;

-- STEP 5: Create non-unique index
CREATE INDEX `idx_bids_inquiry_supplier` ON `bids` (`inquiryId`, `supplierId`);

-- STEP 6: Recreate foreign keys (optional - for data 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 7: Verify
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId`);
-- Should show Non_unique = 1

