Skip to content

[BUG] v0.9.1 and above sends plan output to stderr #244

Closed

Description

@tonycosentini

Describe the bug**

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

  1. added
    bug
    on Sep 2, 2025
  2. changed the title [-][BUG] v0.9.1 sends plan output to stderr[/-] [+][BUG] v0.9.1 and above sends plan output to stderr[/+] on Sep 2, 2025
  3. Navbryce commented on Sep 2, 2025

    @Navbryce
    Collaborator

    Yes! The command syntax has been updated to be more flexible. The new syntax should look like:

    pg-schema-diff plan --from-dsn postgresql://postgres@localhost/pg_schema_diff_test --to-dir schema_dir --output-format json 2>/dev/null
    

    If that does not work, could you send me the output to stderr? Thanks!

  4. tonycosentini commented on Sep 2, 2025

    @tonycosentini
    ContributorAuthor

    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.

  5. bplunkett-stripe commented on Sep 2, 2025

    @bplunkett-stripe
    Contributor

    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

  6. tonycosentini commented on Sep 2, 2025

    @tonycosentini
    ContributorAuthor

    Insane turnaround! Yeah, it works as expected now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions