-- Migration Doctor snapshot, SQL export: all dashboards with owner username. -- Read-only: a single SELECT, no writes, no temporary tables. Output: one JSON object per line. -- Run (read-only) with psql and save the output as dashboards.jsonl: -- psql -X -q -A -t -v ON_ERROR_STOP=1 -h DBHOST -U READONLY_USER -d JIRADB -f dashboards.sql -o export/dashboards.jsonl -- If the Jira tables are not in the default search_path, set PGOPTIONS='-c search_path=your_schema' first. -- Then pass the export directory to the snapshot script: --sql-export-dir export (bash) or -SqlExportDir export (PowerShell). WITH owner_name AS ( SELECT a.user_key, COALESCE((SELECT u.user_name FROM cwd_user u JOIN cwd_directory d ON d.id = u.directory_id AND d.active = 1 WHERE u.lower_user_name = a.lower_user_name ORDER BY d.directory_position LIMIT 1), a.lower_user_name) AS user_name FROM app_user a ) SELECT json_build_object( 'id', pp.id, 'name', pp.pagename, 'owner', CASE WHEN pp.username IS NULL THEN NULL ELSE COALESCE(o.user_name, pp.username) END) FROM portalpage pp LEFT JOIN owner_name o ON o.user_key = pp.username ORDER BY pp.id;