-- ============================================
-- ALTERNATIVE METHODS TO FIND FOREIGN KEY CONSTRAINTS
-- Try these different queries to find constraint names
-- ============================================

-- METHOD 1: Query INFORMATION_SCHEMA (most reliable)
SELECT 
    CONSTRAINT_NAME,
    TABLE_NAME,
    COLUMN_NAME,
    REFERENCED_TABLE_NAME,
    REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids'
  AND REFERENCED_TABLE_NAME IS NOT NULL;

-- METHOD 2: Query REFERENTIAL_CONSTRAINTS table
SELECT 
    CONSTRAINT_NAME,
    TABLE_NAME,
    REFERENCED_TABLE_NAME
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids';

-- METHOD 3: Query TABLE_CONSTRAINTS
SELECT 
    CONSTRAINT_NAME,
    CONSTRAINT_TYPE
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids'
  AND CONSTRAINT_TYPE = 'FOREIGN KEY';

-- METHOD 4: Try with different database name
-- Replace 'your_database_name' with your actual database name
SELECT 
    CONSTRAINT_NAME,
    TABLE_NAME,
    COLUMN_NAME,
    REFERENCED_TABLE_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = 'your_database_name'
  AND TABLE_NAME = 'bids'
  AND REFERENCED_TABLE_NAME IS NOT NULL;

-- METHOD 5: Get all constraints on bids table
SELECT 
    CONSTRAINT_NAME,
    CONSTRAINT_TYPE
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'bids';

-- ============================================
-- COMMON CONSTRAINT NAMES TO TRY
-- ============================================
-- If queries above don't work, try dropping these common names:

-- Try these one by one (uncomment and run):
-- 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_inquiryId_fk`;
-- ALTER TABLE `bids` DROP FOREIGN KEY `bids_supplierId_fk`;
-- ALTER TABLE `bids` DROP FOREIGN KEY `bids_inquiry_id_supplier_id`;

