Skip to main content

Migration engine for MongoDB

Project description

MongoDb Migrator

Migration engine for MongoDB
Supports CLI

Installation

$ python -m pip install mmigrator

Configuration

init command (see below) will create a mmigrator.config.json file with following structure:

{
    "dist": "migrations",
    "connection": {
        "host": "",
        "port": "",
        "database": "",
        "user": "",
        "password": ""
    }
}

Connection variables could be set from .env|.json files.
e.g. from .env file:

{
  "host": ".env[MONGO_HOST]",
  "port": ".env[MONGO_PORT]",
  "database": ".env[MONGO_DB]",
  "user": ".env[MONGO_USER]",
  "password": ".env[MONGO_PASSWORD]"
}

Usage

Help

$ mmigrator help

Init configs

optional, will run automatically on any migration command*

CLI

$ mmigrator init

from code:

from mmigrator import MigrationManager
...
MigrationManager.init()

Create migration

CLI

$ mmigrator g SomeName
# or
$ mmigrator new SomeName

from code:

MigrationManager.generate("SomeName")

Run migrations

CLI

$ mmigrator migrate # or mmigrator run

# add --silent flag for dry-run (skip exceptions)
$ mmigrator migrate --silent

from code:

MigrationManager.migrate() # or MigrationManager.run()

# add silent=True flag for dry-run (skip exceptions)
MigrationManager.migrate(silent=True)

Revert migrations

CLI

$ mmigrator revert # or mmigrator rollback

# add --silent flag for dry-run (skip exceptions)
$ mmigrator revert --silent

from code:

MigrationManager.revert() # or MigrationManager.rollback()

# add silent=True flag for dry-run (skip exceptions)
MigrationManager.revert(silent=True)

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

mmigrator-0.2.6.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mmigrator-0.2.6-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file mmigrator-0.2.6.tar.gz.

File metadata

  • Download URL: mmigrator-0.2.6.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for mmigrator-0.2.6.tar.gz
Algorithm Hash digest
SHA256 47d3258baa4b7a97f5465f3107eb66c0a28a7c8bbed4a23bf59411b91a3926f9
MD5 2332396945ac918c72a6327cc00bf265
BLAKE2b-256 ff4159c96e128be488751296c08beb8c29ad49d4fe60c42b5f01095d18f08d26

See more details on using hashes here.

File details

Details for the file mmigrator-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: mmigrator-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for mmigrator-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dec078f0d280a93150cd6746a487022b3fd821b3e801e6f34be1717a783e4376
MD5 b3293aa0d3565f04cb13dceb3beb2c22
BLAKE2b-256 832c309b2619e2e7c5e1fc850f40c8fd9caaa564266b3d8bb8375e4480e44d3d

See more details on using hashes here.

Supported by

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