https://github.com/bliblidotcom/data-migration-example
Example Data Migrations Projects
https://github.com/bliblidotcom/data-migration-example
Last synced: 3 months ago
JSON representation
Example Data Migrations Projects
- Host: GitHub
- URL: https://github.com/bliblidotcom/data-migration-example
- Owner: bliblidotcom
- Created: 2017-12-12T12:59:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-12T13:12:53.000Z (over 7 years ago)
- Last Synced: 2025-01-23T16:11:35.446Z (5 months ago)
- Language: Java
- Size: 4.88 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blibli Database Migration
This project used by blibli.com as database migration for every microservices in blibli.com
This project support :
- PostgreSQL, using JOOQ
- MongoDB, using Mongodb Java Driver
- Elasticsearch, using OkHTTP
- Apache Cassandra, using Datastax Java DriverCurrently blibli.com only using those datastores.
## Create Migration Script
To create new migration script, we can using generator with command :
```mvn spring-boot:run -Dmode=create```
This will create new `Migration_yyyyMMddHHmmss.java` file in `src/main/java/migrations` directory
## Multi Profiles
Blibli data migration project support multi profiles, you can add your config profile in `src/main/resources/application-YOURPROFILE.properties`. For example you can create profile, local, development, production, uat, etc.
Every time you running the migration, you need to tell your active profile with parameter `-Drun.profiles=YOURPROFILE`
## Run Migration
After you finish create your migration script, you can start migration process using command :
```mvn spring-boot:run -Drun.profiles=your-profile -Dmode=migrate```
## Rollback Migration
If you want to rollback the migration to specific VERSION, you can using command :
```mvn spring-boot:run -Drun.profiles=your-profile -Dmode=rollback -Dversion=VERSION```
Where version is `yyyyMMddHHmmss` in your migration class. If you want to rollback all, just use version `0`
## Build Jar
After you finish create migration, you can package as single jar using :
```mvn package```
## Run in Production
If you want to run in production, first, you need to create configuration file, and run the jar using this command :
```java -Dmode=(migrate/rollback) -jar your-data-migration.jar --spring.config.location=/path/to/application.properties```