-- Add is_active column to products table if it doesn't exist
SET @dbname = DATABASE();
SET @tablename = 'products';
SET @columnname = 'is_active';
SET @preparedStatement = (SELECT IF(
  (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
   WHERE TABLE_SCHEMA = @dbname
     AND TABLE_NAME = @tablename
     AND COLUMN_NAME = @columnname) > 0,
  'SELECT 1',
  'ALTER TABLE products ADD COLUMN is_active TINYINT(4) DEFAULT 1 AFTER is_hot'
));
PREPARE stmt FROM @preparedStatement;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
