-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to output JSON #350
Comments
Ye I'd like to see this as well. Should be a fairly straightforward add, just need to define the returned structs. I might give this a go in the next few days. |
The plan is to make JSON output, for all commands, natively supported in #379. One thing I'm currently thinking through is the user experience when relying on happy path:{
"migrations": [
{
"migration_type": "sql",
"version": 1,
"filename": "00001_add_table.sql",
"duration_ms": 17,
"direction": "up",
"empty": false
},
{
"migration_type": "sql",
"version": 2,
"filename": "00002_fill_lots_of_data.sql",
"duration_ms": 889,
"direction": "up",
"empty": false
},
{
"migration_type": "sql",
"version": 3,
"filename": "00003_create_concurrent_index.sql",
"duration_ms": 1153,
"direction": "up",
"empty": false
}
],
"total_duration_ms": 2090,
"message": "successfully ran 3 migrations in 2.09s"
} unhappy path:In this particular case, we have 2 valid migrations files and 1 invalid migration file. Running The best we can do (if the goal is to retain JSON output) is to surface a new {
"migrations": [
{
"migration_type": "sql",
"version": 1,
"filename": "00001_add_table.sql",
"duration_ms": 9,
"direction": "up",
"empty": false
},
{
"migration_type": "sql",
"version": 2,
"filename": "00002_fill_lots_of_data.sql",
"duration_ms": 947,
"direction": "up",
"empty": false
},
{
"migration_type": "sql",
"version": 3,
"filename": "00003_create_concurrent_index.sql",
"duration_ms": 1,
"direction": "up",
"empty": false,
"error": "ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block (SQLSTATE 25001)"
}
],
"total_duration_ms": 987,
"message": "partial migration error: ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block (SQLSTATE 25001)"
} |
Has there been any recent movement on this? Goose is a nice migration tool and I'm working on writing a Java wrapper for its CLI. The stdout isn't too hard to parse, but JSON output would make the parsing feel significantly less brittle. |
It would be great to have a
--json
or--format json
flag to force all output to be json linesUse-case: we're running goose in a service, and we expect any output from our service to be JSON. We could parse the output + reoutput as JSON or just collect all output and output as a single string, but it'd be nicer to have that output out of the box
Related: #225
The text was updated successfully, but these errors were encountered: