On 5/16/19 9:41 AM, Benedict Holland wrote:
I need a tool that can track schema changes in a postgesql database, write scripts to alter the tables, and store those changes in git. Are there tools that exist that can do this?

BTW, I know if I use a framework with some form of model tracking (laravel and Django), those can do it. The application I am writing does not track model files and I really cannot compare sql schema dumps across versions. It would be far too time-consuming.

For Python database migrations when I'm not using Django or SQLAlchemy I've enjoyed yoyo migrations:

https://ollycope.com/software/yoyo/latest/

If you are using SQLAlchemy then I'd go with Alembic:

https://pypi.org/project/alembic/

Btw I don't *think* this is what you're looking for, but on the Postgres side you can also set `log_statement='ddl'` to audit the changes:

https://blog.hagander.net/why-are-you-not-logging-your-ddl-142/

Or for something more elaborate you could use Event Triggers. The docs have an example you could start from:

https://www.postgresql.org/docs/current/event-trigger-example.html

--
Paul              ~{:-)
p...@illuminatedcomputing.com


Reply via email to