Skip to main content

HEY WATCHOUT THIS IS IN NO WAY GURANTEED TO WORK.

[Documentation Work in Progress]

“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 use-case that was the inspiration of this tool is adding a migration to a feature using CI

When we develop a feature we implement the following:

  • the feature

  • tests

  • necessary migrations that move the production data to where it needs to be to rock the new feature

So now with monarch we can implement a Pull Request(PR) with the feature, test and migration. And once your Continuous Integration says that your tests are cool then you can deploy and run the pending migrations needed for your feature.

Install

pip install monarch

Usage

  1. Configure

In your application working directory run:

monarch init

This will create a migration/settings.py file for you. Open it up and configure it to your needs.

  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
}

You can run monarch init to setup the initial file

Road Map

  • Be able to test migrations monarch test

Release files for monarch 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for monarch 0.0.4
File Size Uploaded
monarch-0.0.4.tar.gz 7.1 kB Details

Release files / monarch-0.0.4.tar.gz

Download URL monarch-0.0.4.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4a2d27f96197d87f87b977ec30b67fd14bdd4e0272aa303f6ed4f8ed411bff51
BLAKE2b-256 checksum
How to use checksums
720290d721a2c9360f6207581c20d30e216dd9df7a4c5affd94e9b73ab3e35f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page