-- STEP-BY-STEP: Allow multiple bids from the same supplier for the same inquiry
-- Run these commands one by one in phpMyAdmin or MySQL command line

-- STEP 1: Check what indexes exist on the bids table
-- This will show you the exact index name you need to drop
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId');

-- Look for an index where Non_unique = 0 (meaning it's UNIQUE)
-- Note the Index_name column - that's what you'll drop in Step 2

-- STEP 2: Drop the unique index
-- Replace 'INDEX_NAME_HERE' with the actual index name from Step 1
-- Common names might be:
--   - 'bids_inquiryId_supplierId_unique'
--   - 'bids_inquiryId_supplierId'
--   - 'inquiryId_supplierId'
--   - Or something else shown in Step 1

ALTER TABLE `bids` DROP INDEX `INDEX_NAME_HERE`;

-- If you get an error saying the index doesn't exist, that's okay - it might already be dropped
-- If you get an error with a different index name, check Step 1 again and use the correct name

-- STEP 3: Create a non-unique index for better query performance
-- This allows multiple bids from the same supplier
CREATE INDEX `idx_bids_inquiry_supplier` ON `bids` (`inquiryId`, `supplierId`);

-- If you get an error saying the index already exists, that's fine - skip this step

-- STEP 4: Verify the change
-- Run this to confirm the index is now non-unique (Non_unique should be 1)
SHOW INDEX FROM `bids` WHERE Column_name IN ('inquiryId', 'supplierId');

-- You should see Non_unique = 1, which means duplicates are now allowed!

