Is there a tool for transferring a schema to a git with change tracking? Something like django migrations for bare sql?

Is there a migration generator that can make the transition from state A to B?

I do not want to look for dozens of ALTER TABLE and DROP VIEW / CREATE VIEW in the log and create patches manually

  • pgquarrel can? or sqitch? - eri

2 answers 2

For the general case, the solution problem is not theoretical.

Simple example from

create table foo (id serial, description text); 

AT

  create table foo (id serial, username varchar(50)); 

It is possible to achieve both by renaming with changing data type, and by deleting and adding a column. The results at the data level will be different, and it is the developer who must decide what has changed here.

You can see what basically has changed in the database, you can pg_dump -s data scheme dump and see the diff . Quite a working idea is also the night crowns, which takes a dump of the scheme from the production master database and saves it to git . So there is a history of real changes in the combat base.

  • Here each object in a separate file - then it is possible and to look. And so it is all difficult. - eri
  • DDL / DML by description is something similar - eri

pgCodeKeeper ( http://pgcodekeeper.org/ ) is a tool that facilitates the management of the data structure and stored procedures in PL / PgSQL. Based on Eclipse. See also the article on Habré ( https://habr.com/post/276339/ ) and there is a telegram channel (t.me/pgcodekeeper)