-- Migration Doctor snapshot, SQL export: group names from all active directories (complete list; REST caps it). -- 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 groups.jsonl: -- psql -X -q -A -t -v ON_ERROR_STOP=1 -h DBHOST -U READONLY_USER -d JIRADB -f groups.sql -o export/groups.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). SELECT json_build_object( 'name', g.group_name) FROM cwd_group g JOIN cwd_directory d ON d.id = g.directory_id AND d.active = 1 WHERE g.active = 1 AND d.directory_position = ( SELECT MIN(d2.directory_position) FROM cwd_group g2 JOIN cwd_directory d2 ON d2.id = g2.directory_id AND d2.active = 1 WHERE g2.lower_group_name = g.lower_group_name AND g2.active = 1) ORDER BY g.lower_group_name;