Regularly migrates production database and schema to the Stage and v2 Prod Databases
For Stage the following actions are performed:
- Dump the production database (all data for Stage)
- Rebuild the database from the given dump file
- Update the database with all updates defined in the
dev_scripts.sql
file - Create a database user for the database with CRUD permissions
This repository is cloned within the Automation Manager droplet. It will sync the production database environment to the stage database environment on a daily basis.
It requires the following environment variables to be set:
- PROD_DB_CONN_STRING: The connection string for the production database, used to dump the database
- STG_ADMIN_DB_CONN_STRING: The connection string for the admin database for the stage, used to create the database
- STG_TARGET_DB_CONN_STRING: The connection string for the target database for the stage, used to restore the dump
- STG_DB_USER: The database user with CRUD permissions to be created for the stage database
- STG_DB_PASSWORD: The password for the database user with CRUD permissions to be created for the stage database
To set up the repository to properly run the associated operation, perform the following actions:
chmod +x *
docker build -t prod-migration .
docker run -it prod-migration
./stg_migration_runner.sh