-- 026_director_split_fields.sql
-- Split director name into first/middle/last for BC Registry (COLIN) compatibility.
-- Add mailing address and additional directors support.

BEGIN;

-- Split director name fields
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS director_first_name TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS director_middle_name TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS director_last_name TEXT;

-- Director mailing address (if different from delivery address)
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS director_mailing_different BOOLEAN DEFAULT FALSE;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS director_mailing_address TEXT;

-- Additional directors (JSON array of objects)
-- Each object: {first_name, middle_name, last_name, street, city, province, postal, country}
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS additional_directors JSONB;

-- BC incorporation results (populated by frappe_ca_registry after filing)
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS bc_incorporation_number TEXT;
ALTER TABLE canada_crtc_orders ADD COLUMN IF NOT EXISTS company_name_final TEXT;

COMMIT;
