Skip to main content

The un-migration migration tool

Project description

HEY WATCHOUT THIS IS IN NO WAY GURANTEED TO WORK. HALF IMPLEMENTED FEATURES

“migrations should happen naturally”

Build Status

monarch is a migration CLI (command line interface) to help manage developers with migrations.

What makes monarch unique is what it does not supply:

  • monarch does not provide a DSL or DDL for database specific migrations (like South and alembic)

  • monarch does not care which database you use, mongo, postres – it does matter to us

The main usecase that was the inspiration of this tool is adding a migration to a feature using CI

[Documentation Work in Progress]

Install

pip install monarch

Usage

  1. Generate a Migration

monarch create add_indexes_to_user_table

That will create a template migration that looks something like this

# in ./migrations/_201405290038_add_indexes_to_user_table_migration.py

from monarch import MongoBackedMigration

class AddIndexesToUserTableMigration(MongoBackedMigration):

    def run(self):
        """Write the code here that will migrate the database from one state to the next
        No Need to handle exceptions -- we will take care of that for you
        """
        raise NotImplementedError
  1. Implement the Migration

Do whatever you want in that run method. I mean anything! Go crazy wild man.

  1. When the time is right, run the pending migrations:

monarch migrate

Configuration

By default it will look in ./migrations/settings.py.

It should look something like this:

# migrations/settings.py
MONGO_SETTINGS = {
    DB_NAME = 'test_monarch'
    DB_PORT = 27017
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monarch-0.0.1.tar.gz (1.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page