Re: schema change tracking

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: schema change tracking
Date: 2019-05-16 16:59:29
Message-ID: 2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)illuminatedcomputing(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mark Fletcher 2019-05-16 17:06:17 Re: schema change tracking
Previous Message David G. Johnston 2019-05-16 16:53:37 Re: Permissions for information_schema