-- Organization settings: currency, locale, defaults, feature toggles, branding
-- Adds configurable preferences to the organizations table

-- ============================================================
-- 1. Preferences (currency, locale, calendar)
-- ============================================================
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS currency TEXT NOT NULL DEFAULT 'EUR';
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS date_format TEXT NOT NULL DEFAULT 'DD/MM/YYYY';
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS timezone TEXT NOT NULL DEFAULT 'Europe/Tallinn';
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS week_start_day TEXT NOT NULL DEFAULT 'monday'
  CHECK (week_start_day IN ('monday', 'sunday'));
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS default_calendar_view TEXT NOT NULL DEFAULT 'month'
  CHECK (default_calendar_view IN ('month', 'week', 'day'));

-- ============================================================
-- 2. Event defaults
-- ============================================================
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS default_event_color TEXT NOT NULL DEFAULT '#7986cb';
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS default_event_status TEXT NOT NULL DEFAULT 'planning';
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS default_dept_modules TEXT[] NOT NULL DEFAULT ARRAY['kanban', 'files', 'checklist'];
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS default_dept_layout TEXT NOT NULL DEFAULT 'split';

-- ============================================================
-- 3. Feature toggles
-- ============================================================
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS feature_chat BOOLEAN NOT NULL DEFAULT true;
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS feature_sponsors BOOLEAN NOT NULL DEFAULT true;
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS feature_contacts BOOLEAN NOT NULL DEFAULT true;
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS feature_budget BOOLEAN NOT NULL DEFAULT true;

-- ============================================================
-- 4. Branding / description
-- ============================================================
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS description TEXT DEFAULT '';
