pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Jungwirth <pj@illuminatedcomputing.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: schema change tracking
Date: Thu, 16 May 2019 09:59:29 -0700
Message-ID: <2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com> (raw)
In-Reply-To: <CAD+mzozAAVSGMMKwQEQh0ZMQtysxuaB2qBqksEv5wXcPJBD8Gw@mail.gmail.com>
References: <CAD+mzozAAVSGMMKwQEQh0ZMQtysxuaB2qBqksEv5wXcPJBD8Gw@mail.gmail.com>

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





view thread (7+ messages)  latest in thread

Message-ID: <2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com>
Permalink:  ../2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com/
Also on:    postgresql.org/message-id/2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: pj@illuminatedcomputing.com
  Subject: Re: schema change tracking
  In-Reply-To: <2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com>
  References: <CAD+mzozAAVSGMMKwQEQh0ZMQtysxuaB2qBqksEv5wXcPJBD8Gw@mail.gmail.com> <2ee69bab-73f2-5455-04bb-38db8a317789@illuminatedcomputing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox