-- 007: National ID as RESTRICTED member data (owner-provided official roster, 2026-10-27)
-- Lives in member_contacts (the restricted-data table): masked by default, revealed only
-- with members.view_contact_details + per-read audit — same treatment as phone/email.
-- Retention policy for it falls under DEC-03 (open).

-- +up
ALTER TABLE member_contacts ADD COLUMN national_id VARCHAR(14) NULL;
ALTER TABLE member_contacts ADD CONSTRAINT ck_member_contacts_nid
  CHECK (national_id IS NULL OR national_id ~ '^[0-9]{14}$');

-- +down
ALTER TABLE member_contacts DROP CONSTRAINT IF EXISTS ck_member_contacts_nid;
ALTER TABLE member_contacts DROP COLUMN IF EXISTS national_id;
