Flyway DB Schema Migration 🕊 - lyes-sefiane/microservices-monitoring-and-observability GitHub Wiki
Table Of Contents
Bash Script Executable
mitsuke ( ◥◣_◢◤ ) : ~/eclipse-workspace/network-device-inventory$ chmod +x scripts/inventory-profile-deployment/network-device-inventory-flyway-db-schema-migration-script
Flyway DB Schema Migration
SQL Migration
Schema Migration from : V1 -> V2
DDL V1__init.sql : Database-Modeling-and-Design#data-definition-language
mitsuke ( ◥◣_◢◤ ) : ~/eclipse-workspace/network-device-inventory/flyway-service/sql_versions$ ll
total 16
drwxrwxr-x 2 lsefiane lsefiane 4096 Jan 1 23:41 ./
drwxrwxr-x 3 lsefiane lsefiane 4096 Jan 1 19:26 ../
-rw-rw-r-- 1 lsefiane lsefiane 740 Jan 1 17:22 V1__init.sql
-rw-rw-r-- 1 lsefiane lsefiane 68 Jan 1 23:34 V2__add_description_column_to_table_network_device.sql
DDL V2__add_description_column_to_table_network_device
mitsuke ( ◥◣_◢◤ ) : ~/eclipse-workspace/network-device-inventory/flyway-service/sql_versions$ cat V2__add_description_column_to_table_network_device.sql
ALTER TABLE network_device
ADD description VARCHAR (255) NOT NULL;
Execute Migration
Successfully applied 1 migration to schema "public", now at version v2 (execution time 00:00.037s)
mitsuke ( ◥◣_◢◤ ) : ~/eclipse-workspace/network-device-inventory$ ./scripts/inventory-profile-deployment/network-device-inventory-flyway-db-schema-migration-script
███╗ ██╗███████╗████████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗██╗ ██╗██╗ ██████╗███████╗
████╗ ██║██╔════╝╚══██╔══╝██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝ ██╔══██╗██╔════╝██║ ██║██║██╔════╝██╔════╝
██╔██╗ ██║█████╗ ██║ ██║ █╗ ██║██║ ██║██████╔╝█████╔╝ ██║ ██║█████╗ ██║ ██║██║██║ █████╗
██║╚██╗██║██╔══╝ ██║ ██║███╗██║██║ ██║██╔══██╗██╔═██╗ ██║ ██║██╔══╝ ╚██╗ ██╔╝██║██║ ██╔══╝
██║ ╚████║███████╗ ██║ ╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗ ██████╔╝███████╗ ╚████╔╝ ██║╚██████╗███████╗
╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚═╝ ╚═════╝╚══════╝
██╗███╗ ██╗██╗ ██╗███████╗███╗ ██╗████████╗ ██████╗ ██████╗ ██╗ ██╗
██║████╗ ██║██║ ██║██╔════╝████╗ ██║╚══██╔══╝██╔═══██╗██╔══██╗╚██╗ ██╔╝
██║██╔██╗ ██║██║ ██║█████╗ ██╔██╗ ██║ ██║ ██║ ██║██████╔╝ ╚████╔╝
██║██║╚██╗██║╚██╗ ██╔╝██╔══╝ ██║╚██╗██║ ██║ ██║ ██║██╔══██╗ ╚██╔╝
██║██║ ╚████║ ╚████╔╝ ███████╗██║ ╚████║ ██║ ╚██████╔╝██║ ██║ ██║
╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
███████╗██╗ ██╗ ██╗██╗ ██╗ █████╗ ██╗ ██╗ ██████╗ ██████╗ ███████╗ ██████╗██╗ ██╗███████╗███╗ ███╗ █████╗
██╔════╝██║ ╚██╗ ██╔╝██║ ██║██╔══██╗╚██╗ ██╔╝ ██╔══██╗██╔══██╗ ██╔════╝██╔════╝██║ ██║██╔════╝████╗ ████║██╔══██╗
█████╗ ██║ ╚████╔╝ ██║ █╗ ██║███████║ ╚████╔╝ ██║ ██║██████╔╝ ███████╗██║ ███████║█████╗ ██╔████╔██║███████║
██╔══╝ ██║ ╚██╔╝ ██║███╗██║██╔══██║ ╚██╔╝ ██║ ██║██╔══██╗ ╚════██║██║ ██╔══██║██╔══╝ ██║╚██╔╝██║██╔══██║
██║ ███████╗██║ ╚███╔███╔╝██║ ██║ ██║ ██████╔╝██████╔╝ ███████║╚██████╗██║ ██║███████╗██║ ╚═╝ ██║██║ ██║
╚═╝ ╚══════╝╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
███╗ ███╗██╗ ██████╗ ██████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗
████╗ ████║██║██╔════╝ ██╔══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║
██╔████╔██║██║██║ ███╗██████╔╝███████║ ██║ ██║██║ ██║██╔██╗ ██║
██║╚██╔╝██║██║██║ ██║██╔══██╗██╔══██║ ██║ ██║██║ ██║██║╚██╗██║
██║ ╚═╝ ██║██║╚██████╔╝██║ ██║██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║
╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
Linux : Hi 😊 ! please make a selection.
1) Flyway DB Schema Migration
2) quit
#? 1
SQL Migration file is required for this procedure. It should be added in : deployment/flyway/sql_versions
In order to be picked up by Flyway, SQL migration file must comply with a certain naming convention : https://flywaydb.org/documentation/concepts/migrations.html#naming
Continue ? [y|n] y
Flyway DB Schema Migration...
postgreSQL is up-to-date
Starting flyway ... done
Attaching to flyway
flyway | 2022-01-02T15:21:18.206300852Z Successfully applied 1 migration to schema "public", now at version v1 (execution time 00:00.061s)
flyway | 2022-01-02T15:22:36.232464241Z Flyway Teams Edition 8.3.0 by Redgate
flyway | 2022-01-02T15:22:36.236686892Z Database: jdbc:postgresql://postgres:5432/network_device_inventory (PostgreSQL 14.1)
flyway | 2022-01-02T15:22:36.262210399Z ----------------------------------------
flyway | 2022-01-02T15:22:36.262407702Z Flyway Teams features are enabled by default for the next 27 days. Learn more at https://rd.gt/3A4IWym
flyway | 2022-01-02T15:22:36.262569504Z ----------------------------------------
flyway | 2022-01-02T15:22:36.282814848Z Successfully validated 2 migrations (execution time 00:00.017s)
flyway | 2022-01-02T15:22:36.293210173Z Current version of schema "public": 1
flyway | 2022-01-02T15:22:36.308195254Z Migrating schema "public" to version "2 - add description column to table network device"
flyway | 2022-01-02T15:22:36.323510638Z Successfully applied 1 migration to schema "public", now at version v2 (execution time 00:00.038s)