-- =========================================================
-- 107_warehouse_groups_digital_production_flag.sql
-- Tambah flag resmi grup gudang untuk sumber bahan Produksi Digital
-- =========================================================

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

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

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