Upgrade to Pro — share decks privately, control downloads, hide ads and more …

XHotel Database Migration

XHotel Database Migration

Database Migration Tools for XHotel Project

Eko Kurniawan Khannedy

October 11, 2016
Tweet

More Decks by Eko Kurniawan Khannedy

Other Decks in Technology

Transcript

  1. What is Database Migrations Migrations are a convenient way to

    alter your database schema over time in a consistent and easy way. https://en.wikipedia.org/wiki/Schema_migration You can think of each migration as being a new 'version' of the database. A schema starts off with nothing in it, and each migration modifies it to add or remove tables, columns, or entries. Database Migrations knows how to update your schema along this timeline, bringing it from whatever point it is in the history to the latest version.
  2. Why Database Migrations Easy to create database apps in every

    environment (local, uat, production), just run the database migration. Easy to track database changes (for code review) before run in production. Easy to rollback if something wrong in new migration script. Consistent default data in every database environment (local, uat, production).
  3. Current Database Migrations In Blibli currently we are using FlywayDB

    and Mongobee for database migrations. All FlywayDB and Mongobee script will be included in the app. For Elasticsearch, we manually create schema using CURL, ups! 
  4. Problem With Current Database Migrations (1) Every times we create

    new migration script, we need to redeploy the app, because migration script embedded in the app, even there is no changes in the app . For microservice that using more than one datastore, like x-fraud (using mongodb and elasticsearch), it’s a nightmare . If there is hot fix migration script, engineer will send request to dbadmin using JIRA. And it’s hard to track the migration script if using JIRA. For new engineer, good luck, you can not simulate migration from the first database creation, if you want to setup the database in your local computer, please dump the database from UAT 
  5. Problem With Current Database Migrations (1) Something wrong with our

    last 2 migration scripts, let’s rollback the migrations. Ups, but wait? How to rollback the migrations? Hmm, just create new migrations that rollback the last 2 migration script. Oh, ok  I already rollback the mongodb migrations, but it’s still broken, the app is not working. Ups, sorry I forget, you also need to rollback the schema in elasticsearch. Etc.
  6. The Project The project created as a template project, so

    every one can fork the project if want to create database-migration project for their apps. You can get the project template here : https://stash.gdn-app.com/projects/SANDBOX/repos/database- migration/browse For example, hotel-search fork and create new database-migration project here : https://stash.gdn-app.com/projects/HOTEL/repos/hotel-search- database/browse
  7. Project Technology Database-migration project build using JRuby (Ruby Implementation on

    JVM). Ruby is developer friendly language, simple and dynamic, we don’t need to compile the project, just write and run. For Relational Database, the project using http://sequel.jeremyevans.net/ library. For MongoDB, the project using https://docs.mongodb.com/ruby- driver/master/ For Elasticsearch, the project using https://github.com/jnunemaker/httparty
  8. Project Configuration Database-migration project support multi environment We can create

    local, uat1, uat2 and another configuration just in one project.