Skip to content
Emigrate is Python MySQL database migration tool
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Emigrate is Python application for create and manage database migration (now support only MySQL).

Quick start

  1. Initialize migration system

    $ python -m emigrate init
  2. Creating new migration in ".migration" directory:

    $ python -m emigrate create
  3. Change migration source code

    class Migration_20140212165434(Migration):
        """ Create `users` tables and insert admin account
        def up(self):
            """ Update
            - Create table `users`
            - Create table `user_pendings`
            query = "CREATE TABLE `users` ..."
            query = "CREATE TABLE `user_pending` ..."
        def down(self):
            """ Revert
            - Delete table `users`
            - Delete table `user_pending`
            query = "DROP TABLE `users`"
            query = "DROP TABLE `user_pending`"
  4. Setup environment in "emigrate.xml"

    <?xml version="1.0" encoding="utf-8" ?>
    <emigrate version="0.5">
        <connection name="default">
            <option name="driver" value="mysql" />
            <option name="schema" value="smm" />
            <option name="host" value="" />
            <option name="port" value="3333" />
            <option name="username" value="root" />
            <option name="password" value="******" />
  5. Migration command: "status", "up" or "down".

    $ python -m emigrate status


All operation working in autocommit mode by default and you should create transaction scope by hand for working inside transaction.

You may understand that create transaction start in separate connection.

You can’t perform that action at this time.