-- Fix existing configurations to add missing fields
-- Run this if you already have configurations seeded but missing is_sensitive and requires_restart

-- Add default values for missing columns (if columns exist but have NULL values)
UPDATE admin_configurations 
SET 
  is_sensitive = COALESCE(is_sensitive, false),
  requires_restart = COALESCE(requires_restart, false)
WHERE is_sensitive IS NULL OR requires_restart IS NULL;

-- Set requires_restart = true for settings that need backend restart
UPDATE admin_configurations 
SET requires_restart = true
WHERE config_key IN (
  'WORK_START_HOUR',
  'WORK_END_HOUR',
  'MAX_FILE_SIZE_MB',
  'ALLOWED_FILE_TYPES'
);

-- Verify all configurations are editable
UPDATE admin_configurations 
SET is_editable = true
WHERE is_editable IS NULL OR is_editable = false;

-- Show result
SELECT 
  config_key,
  config_category,
  is_editable,
  is_sensitive,
  requires_restart
FROM admin_configurations
ORDER BY config_category, sort_order;

