Postgresql – Migrate schema updates onto existing schema

postgresql

So we have three development environments from a programming point of view.
Each environment has its own postgres database.

Let's say a table gets an extra column in our development environment, we need to update the acceptance environment as well when the code is merged back. Other changes can be column renames etc.

This is needed because we are still developing the app quite heavily, but it is still important that the production environment can keep up on a database level as well.

So the question is: how can I propagate schema updates to a different database without loss of data.

Best Answer

I suggest that you use a tool such as Liquibase or Flyway which is designed to manage such schema changes in a database and keep the configurations consistent and known.

http://www.liquibase.org/

https://flywaydb.org/

There are other tools available and they usually have plugins to maven, Puppet & Chef etc...it'll come down to a google search and personal preference.