Many ORM framework like Django, Laravel comes with a nice database migration tool which let us update database schema in ease, also changes in database schema can be version controlled in the git repo. But if I’m not using any of such frameworks then how can I version control my database schema and use database migration to deploy schema changes.
Flyway(flywaydb.org) is an open-source database migration tool that lets me use version control schema and database migrations. No ORM or any relation with my actual service. Just need to name SQL files with a version number.
SQL file naming example:
V1.2__UserAccounts.sql
V1.1__UserAccounts.sql
V1__Initial.sql
Flyway migration CLI command:
flyway migrate -url=... -user=... -password=...
Flyway has an official docker which makes it easy to run in the CI-CD pipeline. Here is my quick-start project for flyway using Postgres and Docker โโโโโโhttps://github.com/ashraful88/flyway-postgres