SET @add_order_item_roast_level = (
  SELECT IF(
    EXISTS (
      SELECT 1 FROM information_schema.columns
      WHERE table_schema = DATABASE()
        AND table_name = 'order_items'
        AND column_name = 'roast_level'
    ),
    'SELECT 1',
    'ALTER TABLE order_items ADD COLUMN roast_level ENUM(''light'', ''medium'', ''dark'') NOT NULL DEFAULT ''medium'' AFTER product_size_id'
  )
);
PREPARE add_order_item_roast_level_stmt FROM @add_order_item_roast_level;
EXECUTE add_order_item_roast_level_stmt;
DEALLOCATE PREPARE add_order_item_roast_level_stmt;

SET @add_recurring_order_item_roast_level = (
  SELECT IF(
    EXISTS (
      SELECT 1 FROM information_schema.columns
      WHERE table_schema = DATABASE()
        AND table_name = 'recurring_order_items'
        AND column_name = 'roast_level'
    ),
    'SELECT 1',
    'ALTER TABLE recurring_order_items ADD COLUMN roast_level ENUM(''light'', ''medium'', ''dark'') NOT NULL DEFAULT ''medium'' AFTER product_size_id'
  )
);
PREPARE add_recurring_order_item_roast_level_stmt FROM @add_recurring_order_item_roast_level;
EXECUTE add_recurring_order_item_roast_level_stmt;
DEALLOCATE PREPARE add_recurring_order_item_roast_level_stmt;
