Skip to content

Database Flyway Migration

Dmitrii Hromtsov edited this page Jan 30, 2023 · 5 revisions

Migration Environment

FlyWay is being used in order to create migrations. Flyway is an industry leading database versioning framework that aims to unlock DevOps for the database. It strongly favors simplicity and convention over configuration.

Initialize database

Manual installation

  1. Create system environment variables

  2. Download latest PostgreSQL and install it on default port (5432) as service.

  3. Create user with credentials

  • db_user
  • db_password
  1. Create business-lunch-provider-db for db_user.

Docker Compose

  1. Run docker-compose.yml database service

Run Backend application. This way FlyWay will automatically create the required blp_schema and apply migrations needed.

Migration versioning

Flyway adheres to the following naming convention for migration scripts: Prefix_Version__Description.sql

Where:

  • Prefix – The default prefix is V, which we can change in the above configuration file using the flyway.sqlMigrationPrefix property.
  • Version – Migration version number. Major and minor versions may be separated by an underscore. The migration version should always start with 1.
  • Description – Textual description of the migration. A double underscore separates the description from the version numbers. Example: V1_1_0__my_first_migration.sql

BLP project uses default versioning starting with V1_0_0__init_ddl.sql as first migration