-- Add TaxCore PAC (Personal Authentication Code) support to organization settings
-- PAC is required when using PFX certificates obtained from the tax authority
-- This is sent as an HTTP header with each invoice request

-- The PAC value is stored in the org settings JSON field
-- Example: {"taxcore_pac": "123456", "vsdc_url": "...", ...}

-- Migration steps:
-- 1. Organizations using PFX certificates from tax authority should update their settings
-- 2. Update org settings JSON to include taxcore_pac field

-- Example UPDATE statement (run per organization as needed):
-- UPDATE orgs 
-- SET settings = jsonb_set(
--     COALESCE(settings::jsonb, '{}'::jsonb),
--     '{taxcore_pac}',
--     '"YOUR_PAC_VALUE_HERE"'
-- )
-- WHERE org_id = 'your-org-id-here' AND isdeleted = false;

-- Note: PAC is optional and only required when:
-- 1. Using installed PFX certificate (not smart card)
-- 2. Certificate was obtained from tax authority
-- 3. You are prompted for PAC during manual certificate use

COMMENT ON COLUMN orgs.settings IS 'JSON settings including: vsdc_url, pfx_cert_path, pfx_password, taxcore_pin, taxcore_pac (optional), tax_api_url';
