SET @has_show_in_digital_production := (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'machine_assets'
    AND COLUMN_NAME = 'show_in_digital_production'
);

SET @sql := IF(
  @has_show_in_digital_production = 0,
  'ALTER TABLE machine_assets ADD COLUMN show_in_digital_production TINYINT(1) NOT NULL DEFAULT 0 AFTER status',
  'SELECT 1'
);

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