2

I have installed 3 Postgres databases.

The first database is the development, the second homologation and the third is production.

I need to replicate the DDL of development with homologation and production, because I need to create columns and tables all the time.

How to replicate this operations, without replicating the database data?

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
  • Check out schema migration tools like Liquibase and Flyway. In a nutshell: you have to store ***ever*** change you apply to your schema in a SQL script, put the script under version control (svn, git) and run the appropriate scripts to migrate a DB schema from version X to version X+1 –  Apr 16 '15 at 13:38
  • 1
    Thanks for your comment, but how to register this changes automatically if im using an IDE to do the changes (pgadmin)? Better if i simple type the create and alter statements instead? With SQL Server i can do this type of replication.... but i dont like SQL Server so much and its still need MS system. – Luciano Andress Martini Apr 16 '15 at 13:42
  • Do ***NOT*** change your objects through a GUI. Create SQL script and test that. If you start doing ad-hoc changes through the GUI you **are** going to get in trouble (this is true for pgAdmin and SSMS) –  Apr 16 '15 at 13:51
  • Thank you for the advice i will stop doing that... Do you know some better alternatives, that generate the sql statements so i can construct the scripts automatically? – Luciano Andress Martini Apr 16 '15 at 13:55
  • `pg_dump --schema-only -Fc` and `pg_restore --clean`. But really, use a change management system. – Craig Ringer Apr 17 '15 at 03:51
  • Craig i will lose data doing this? – Luciano Andress Martini Jun 25 '15 at 13:34

0 Answers0