Re: schema change tracking - Mailing list pgsql-general

From Paul Jungwirth
Subject Re: schema change tracking
Date
Msg-id 2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com
Whole thread Raw
In response to schema change tracking  (Benedict Holland <benedict.m.holland@gmail.com>)
List pgsql-general
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              ~{:-)
pj@illuminatedcomputing.com



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Permissions for information_schema
Next
From: Mark Fletcher
Date:
Subject: Re: schema change tracking