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 add --silent flag for dry-run (skip exceptions)
$ mmigrator migrate --silent

from code:

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

Revert migrations

CLI

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

from code:

MigrationManager.revert()
# or 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.4.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.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mmigrator-0.2.4.tar.gz
Algorithm Hash digest
SHA256 bbad3d9a2e785acb0029b93e7381c108605d5a34381a18fba6e7ee7455524149
MD5 40653e1c2e48c9fc3b211bb2b9767304
BLAKE2b-256 e8e343361bf14e93ad5080082c97998f0083905aace66204a0eb4aea5390b7b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mmigrator-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for mmigrator-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ca99d82f623dca34c65afa2f400b02c311c7e058a5e8755b3a72d7b1552ffb55
MD5 2008f4fe3eb3de3f919210c47ab59267
BLAKE2b-256 b6970e8ede9c39fd324b53e20789fb57aa8fadf71f2c2e82d67bf32713f1941e

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