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.2.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.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mmigrator-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 45081cd4acf0e0f902ccb005a5672f7c845cc45c1c3f132c7cb554d5804aacd7
MD5 387a1eec95bdea78517a2eadc389f978
BLAKE2b-256 f1f427c68a53b8371b63dd1d22472bffbbc08b4398269e98d0c7fbacfd5b4dbc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mmigrator-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b89d1763e821b40193289b86c153c9e96fa75d22dc3a75c02b2fed457e917345
MD5 e2a22098f5ea3c6e785357a9d8311521
BLAKE2b-256 a1acda86507c4567011536a4b5f27d9cf8e039786d7323669ec19bf7b213637a

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