Skip to main content

Migration engine for MongoDB

Project description

MongoDb Migrator

Migration engine for MongoDB

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, wil l 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.0.tar.gz (6.3 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.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mmigrator-0.2.0.tar.gz
  • Upload date:
  • Size: 6.3 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.0.tar.gz
Algorithm Hash digest
SHA256 fc8255c573b70a352a52117a66bb375c080df60d07fca98151b37b6ca083a86c
MD5 2fd20dd4519057bd737a8226a3611dfa
BLAKE2b-256 ade00d9a8bfa1c04b0ed23f5ad28b5162a69a359ad19a232c328923f52a45916

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mmigrator-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2cbc611a176c134ea352deb83ca19279755b8699a49dc57d7d10237bedd4f2c
MD5 11ee36c7e3a4e11cb1d7b263b665b016
BLAKE2b-256 4e4873835b4951a0c39d5b23ecd4a2271c342b657a4bef5bcceb037f4c1d7c6c

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