bikeshedder / tusker

PostgreSQL migration management tool
The Unlicense
208 stars 17 forks source link

better logs ? Error during diff, due to invalid schema #11

Closed rienafairefr closed 2 years ago

rienafairefr commented 3 years ago

I've run into this tool, love the idea of migra and tusker complements it nicely, in order to stop committing endless small migrations files, and just commit the whole schema, goddammit.

I was trying to run tusker diff with a schema.sql generated by a pg_dump --schema-only, modified to remove what I think was useless for the business rules/logic. Apparently the final .sql was somehow invalid (missing a schema creation). But tusker/migra was not showing that error, I just had a sqlalchemy error on the bottom of a long SQL output:

(Background on this error at: https://sqlalche.me/e/14/f405)

Looking into it, the output was actually truncated by my terminal scrollback size, and the eror(psycopg2.errors.InvalidSchemaName: schema "***" does not exist) was all at the top.

I guess one way to have better UI for this would be to catch the exception in or around execute_sql_file, print the error (and not the whole SQL), because you never know maybe the user is a doofus is trying to migrate to an invalid database schema :-)

bikeshedder commented 2 years ago

A PR for that feature would be highly appreciated. :+1: