These scripts used for veriosn managmnet op a postgres DB
- python (https://www.python.org/downloads/)
- expect (Debian: apt-get update && apt-get install -y expect; Mac: sudo port install expect;)
- psql (apt-get update && apt-get install -y postgresql-client; Mac: brew install postgresql@14)
- pyrseas (https://pyrseas.readthedocs.io/en/latest/install.html)
- pip3 install psycopg2
- pip3 install psycopg_c
- pip3 install psycopg_binary
- pip3 install libpq
env variables (scrips will read .env file from ../.env)
- DB_HOST: DB server hostname/ip
- DB_PORT: DB server port
- DB_USER: User with access to DB
- DB_PASSWORD: User password
- DB_DATABASE: Database name to export to yaml
- The following scripts is used for:
- Create a yaml snapshot of a db and store it in the root folder as a yaml file
- Create a diff between the snapshot stored in the root folder and a destenation DB using the snapshot form 1. and saving it the root folder as a sql file
- Create & update a destenation DB (this step runs step 2. and 3. in one script)
Bash script used to create a snapshot from your DEV DB (snpashot will be used to update the production DB)
run:
bash pg-dbtoyaml.sh
Links to docks:
Bash script used to create a diff between snapshot created in section 1 and destenation DB
run:
bash pg-yamltodb.sh
Links to docks:
3. pg-update.sh
Bash script to create diff by calling section 2 and applying the diff created to the destenation DB (used by docker)
run:
bash pg-update.sh