SET @column_exists = (
  SELECT COUNT(*)
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'order'
    AND COLUMN_NAME = 'promo_discount'
);

SET @sql = IF(
  @column_exists = 1,
  'ALTER TABLE `order` DROP COLUMN `promo_discount`',
  'SELECT ''Column promo_discount does not exist in order table'''
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @column_exists = (
  SELECT COUNT(*)
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'order'
    AND COLUMN_NAME = 'promo_rule_id'
);

SET @sql = IF(
  @column_exists = 1,
  'ALTER TABLE `order` DROP COLUMN `promo_rule_id`',
  'SELECT ''Column promo_rule_id does not exist in order table'''
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

DROP TABLE IF EXISTS `promo_usage`;
DROP TABLE IF EXISTS `subscribe_promo`;
DROP TABLE IF EXISTS `promo_rule`;
