-- A/B deney trafik yüzdesi (panel). idempotent

SET @db := DATABASE();

SET @col_exists := (
  SELECT COUNT(*) FROM information_schema.columns
  WHERE table_schema = @db AND table_name = 'ab_experiments' AND column_name = 'traffic_percent'
);
SET @sql := IF(
  @col_exists = 0,
  'ALTER TABLE ab_experiments ADD COLUMN traffic_percent TINYINT UNSIGNED NOT NULL DEFAULT 100 AFTER variants_json',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
