Useful for synchronization of database changes within development team.
composer require davidburger/pgup
- psql client must be installed
# debian/ubuntu:
sudo apt-get install postgresql-client
- PDO_PGSQL driver is required for sync_mode = 'database'
- if
<project_root>/migrations
folder does not exist, it will be created with initial config file
cd <project_root>
./vendor/bin/pgup
- edit database credentials in
<project_root>/migrations/config/global.php
- password for individual hosts are stored in ~.pgpass - see http://www.postgresql.org/docs/9.5/interactive/libpq-pgpass.html
- if ~/.pgpass does not exist, it is created automatically
- sql files could be successfully processed only once for given environment - they are checked for their equivalent stored in "applied" folder (sync_mode = filesystem) or in the database table "migration" (sync_mode = database)
- output is written to the path defined by 'log_dir' configuration variable
- create empty sql migration file from template:
php vendor/bin/pgup create --comment="add_new_table"
- process migration files:
php vendor/bin/pgup
- process migration files for specific environment:
php vendor/bin/pgup --env=development