-- ============================================
-- DFC Remove Credit Sale Column
-- This removes the credit_sale column if it exists
-- (It was removed from UI but may still exist in database)
-- ============================================

-- Remove credit_sale column if it exists
SET @dbname = DATABASE();
SET @tablename = "dfc_entries";
SET @columnname = "credit_sale";

-- Check if column exists and drop it
SET @preparedStatement = (SELECT IF(
  (
    SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
    WHERE table_name = @tablename AND table_schema = @dbname AND column_name = @columnname
  ) > 0,
  CONCAT("ALTER TABLE ", @tablename, " DROP COLUMN ", @columnname),
  "SELECT 1"
));
PREPARE alterIfExists FROM @preparedStatement;
EXECUTE alterIfExists;
DEALLOCATE PREPARE alterIfExists;
