You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] v0.9.1 and above sends plan output to stderr #244
Before 0.9.1, plan output would go to stdout, on 0.9.1 and above, it goes to stderr.
Expected behavior**
The plan should print to stdout.
To Reproduce
On 0.9.1 and above:
pg-schema-diff plan --dsn postgresql://postgres@localhost/pg_schema_diff_test --schema-dir schema_dir --output-format json 2>/dev/null
This won't print anything.
Context
We're using pg-schema-diff in a tool that runs it and grabs the JSON output and parses it. I encountered this when trying to upgrade since it was suddenly getting no output even though the commands weren't failing.
Activity
[-][BUG] v0.9.1 sends plan output to stderr[/-][+][BUG] v0.9.1 and above sends plan output to stderr[/+]Navbryce commentedon Sep 2, 2025
Yes! The command syntax has been updated to be more flexible. The new syntax should look like:
If that does not work, could you send me the output to stderr? Thanks!
tonycosentini commentedon Sep 2, 2025
Sorry, I was bouncing between versions when writing that example. Here's an example running on v1.0.1:
➜ pg-schema-diff git:(main) ✗ pg-schema-diff plan --from-dsn postgresql://postgres@localhost/pg_shcema_diff --to-dir ./test_schema --output-format json { "statements": [ { "ddl": "DROP TABLE \"public\".\"other_table\"", "timeout_ms": 1200000, "lock_timeout_ms": 3000, "hazards": [ { "type": "DELETES_DATA", "message": "Deletes all rows in the table (and the table itself)" } ] } ], "current_schema_hash": "7d30ce7d038fbdd3" } ➜ pg-schema-diff git:(main) ✗ pg-schema-diff plan --from-dsn postgresql://postgres@localhost/pg_shcema_diff --to-dir ./test_schema --output-format json 2>/dev/null ➜ pg-schema-diff git:(main) ✗You can see that when stderr is redirect to /dev/null it doesn't print anything.
If I redirect it to a file, the file will contain the plan that shows up in my terminal in the first example.
bplunkett-stripe commentedon Sep 2, 2025
This PR should have fixed the problem. Let me cut a minor release for it. Let me know if that works for you! Fix is in v1.0.2
tonycosentini commentedon Sep 2, 2025
Insane turnaround! Yeah, it works as expected now.