Thanks to visit codestin.com
Credit goes to github.com

Skip to content

blasterpal/my_migrate

Repository files navigation

MyMigrate

A Simple REPL tool to migrate from MySQL to PostgreSQL. (Beta)

MyMigrate screenshot

Migrating from MySQL to PostgreSQL is not completely straightforward. Based on my experience, I'm not certain if it's possible to have one tool that's preconfigured to reliably migrate 100% of time without any tweaking.

This tool is meant to address some of this. It's simply a small framework to get you running a lot faster in your migration. Good luck!

Requirements

This tool has been created and tested on OSX, however it's very likely it will work fine on Linux for performing work directly on your server(s). I'm not a Haskell expert so that's the part that you'll have to venture on your own.

  • OSX
  • Homebrew
  • Haskell (runghc, cabal). See install script for more info.
  • Ruby 1.9
  • Bundler
  • mysql client
  • psql client
  • network connectivity to both MySQL and PostgreSQL servers

Configure

  • Copy config.yml.example to config.yml adjust to your environment and needs.

  • Copy lib/my_migrate/custom_actions.rb to lib/my_migrate/custom_actions.rb and tweak, see below.

Actions

There are default actions that occur in a typical migration from MySQL to PostgreSQL. Dump DDL, Dump data, transform DDL,etc. All of these are reflected in the "Actions" class in lib/my_migrate/actions.rb. This is effectively where all the work is done. They are simply methods that return a string that will be executed as is in shell.

You can review these actions here and make adjustments if you need to, but CustomActions are for that. Read on.

Custom Actions

Custom actions allow you ability to add your own commands that you need to perform in the workflow of your migration. They are simply methods like in Actions class, that are referenced in actions_set in the config.yml. You place your own custom actions methods in the config, restart the console and you are good to go.

Install requirements

Haskell for using DDL converter ( https://github.com/danchoi/mysql-ddl-parser).

brew install parallel
brew install ghc --64bit --use-llvm
brew install haskell-platform --64bit --use-llvm
cd my_migrate
sh install 

Then bundle

bundle

Start

bundle exec bin/console

You should see the Pry prompt.

[1] pry(main)> 

MyMigrate and actions

MyMigrate is a simple object with a few accessors and methods on those. It's really a couple of accessors and those are filled with Mashes from Hashie Gem.

To list the actions:

[1] pry(main)> MyMigrate.actions.list
=> ["dump_mysql_ddl",
 "fix_timestamps_in_mysql_ddl",
 "convert_mysql_ddl_to_postgres",
 "split_indexes_from_postgres",
 "split_ddl_from_postgres",
 "dump_mysql",
 "fix_nulls",
 "drop_create_target", "load_postgres_ddl",
 "load_csvs",
 "load_postgres_indexes"]

To see the config:

MyMigrate.config

Run everything

MyMigrate.actions.run_all

Testing out without doing anything destructive

Change dry_run to true in config.yml and restart or set via MyMigrate.config like so:

MyMigrate.config.dry_run = true
MyMigrate.actions.run_all

To skip arbitrary actions

MyMigrate.actions.run_and_skip ['load_csvs']

To run until a certain action

MyMigrate.actions.run_until ['update_synchronized_time']

To run a single action

MyMigrate.actions.run 'load_csvs'

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it, tests are a WIP, this tool is a very specific use case.
  • Send me a pull request. Bonus points for topic branches.

Credits

Thanks to @danchoi for creating Haskell parse program to do DDL transformation at https://github.com/danchoi/mysql-ddl-parser

Copyright

Copyright (c) 2013 Hank Beaver and Obie Fernandez

About

MySQL to PostgreSQL migration tool and framework. Provides base steps and assists creating your own workflow for migrating. Because not every migration is the same.

Resources

License

Stars

6 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors