-- Migration Doctor snapshot, SQL export: all saved filters, including other users' private filters, with JQL and owner username. -- Read-only: a single SELECT, no writes, no temporary tables. Output: one JSON object per line. -- Run (read-only) with sqlcmd and save the output as filters.jsonl. JIRA_SCHEMA is the schema of the -- Jira tables (usually jiraschema, sometimes dbo): -- sqlcmd -S DBHOST -d JIRADB -E -v JIRA_SCHEMA=jiraschema -y 0 -f 65001 -i filters.sql -o export/filters.jsonl -- (-E uses Windows authentication; use -U READONLY_USER and let sqlcmd prompt for the password otherwise.) -- Then pass the export directory to the snapshot script: --sql-export-dir export (bash) or -SqlExportDir export (PowerShell). SET NOCOUNT ON; WITH owner_name AS ( SELECT a.user_key, COALESCE((SELECT TOP 1 u.user_name FROM $(JIRA_SCHEMA).cwd_user u JOIN $(JIRA_SCHEMA).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), a.lower_user_name) AS user_name FROM $(JIRA_SCHEMA).app_user a ) SELECT (SELECT s.id AS [id], s.filtername AS [name], CAST(s.description AS NVARCHAR(MAX)) AS [description], CAST(s.reqcontent AS NVARCHAR(MAX)) AS [jql], COALESCE(o.user_name, s.username) AS [owner] FOR JSON PATH, WITHOUT_ARRAY_WRAPPER, INCLUDE_NULL_VALUES) FROM $(JIRA_SCHEMA).searchrequest s LEFT JOIN owner_name o ON o.user_key = s.username ORDER BY s.id;