Urbanise Strata database versioning tool
Urbanise way for updating and versioning database instances used for Strata Management Platform
Read this great article from Petromir Dzhunev.
We use Flyway and Bash for updating and versioning our PostgreSQL RDS instances.
- Install Docker Compose
- Install PostgreSQL client (psql)
- macOS
- Amazon Linux Image (AMI) -
sudo yum install postgresql96 -y
Option | Meaning | Desription | Required |
---|---|---|---|
-d |
URL | Sets database URL. Expected format is <host>:<port>/<db> |
Yes |
-u |
Username | Sets database username. | Yes |
-p |
Password | Sets database password. | Yes |
-s |
Schema | Sets database schema. | Yes |
-f |
SQL scripts folder | Sets the folder where sql scripts are placed. Note that the script directory is used as root. | Yes |
-r |
Rollback | Executes rollback scripts defined in <sql_folder>. | No |
-i |
Ignore | Ignores hot-fix scripts. | No |
-h |
Help | Prints all options | No |
-
Check out the project.
git clone https://github.com/Majitek/strata-db-versioning.git cd strata-db-versioning
-
Run local PostgreSQL server.
docker-compose up -d
-
Use one of these commands depending on specific case. Each of them relies on:
SQL_FOLDER=$(find * -type d -name "sprint*" | sort | tail -n 1)
-
Incremental versioning.
./update_db.sh -d localhost/test -u test -p test -s public -f $SQL_FOLDER
-
Undo previously applied versions.
./update_db.sh -d localhost/test -u test -p test -s public -f $SQL_FOLDER -r
-
Ignoring hot-fixes.
./update_db.sh -d localhost/test -u test -p test -s public -f $SQL_FOLDER -i
-
- The bash script is compatible with GNU and BSD.
- Undo functionality executes all
.rollback
scripts, so for now there is no option to revert only single change. - No file prefix option is provided yet, so script change is required to add yours.
- History table is named
schema_history
, instead offlyway_schema_history
. --net=host
is used as a parameter to Docker run command, which allows accessing local PostgreSQL server.- Depending on your Docker system configuration, you may be required to preface the
docker run
command withsudo
. To avoid having to usesudo
with thedocker
command, your system administrator can create a Unix group calleddocker
and add users to it.
Main contributor is Petromir Dzhunev.
Simply fork repository, make changes and create a pull request. We will review your changes and apply them to the master
branch shortly.
Another option is to open an issue.