Mongoengine-migrate
Framework-agnostic schema migrations for Mongoengine ODM. Inspired by Django migrations system.
WARNING: this is an unstable version of software. Please backup your data before migrating
Installation
pip3 install mongoengine-migrate
Features
- Documents
- Creating, dropping, renaming
- Renaming a collection
- Creating, dropping, renaming of fields
- Converting to/from a
DynamicDocument - Inheritance
- Embedded documents
- Recursive creating, dropping
- Renaming
- Recursive creating, dropping, renaming of fields
- Converting to/from a
DynamicEmbeddedDocument - Inheritance
- Altering fields in document and embedded documents
- Changing of init parameters such as
db_field,required, etc. - Convertion between field types (if possible)
- Changing of init parameters such as
- Indexes
- Creating, dropping, renaming
- Handling fields constraints such as
uniqueandunique_with
- Automatic select a query or a python loop to perform an update depending on MongoDB version
- Two policies of how to work with existing data which does not meet to mongoengine schema
All mongoengine field types are supported, including simple types, lists, dicts, references, GridFS, geo types, generic types.
Typical migration file
from mongoengine_migrate.actions import *
# Existing data processing policy
# Possible values are: strict, relaxed
policy = "strict"
# Names of migrations which the current one is dependent by
dependencies = [
'previous_migration'
]
# Action chain
actions = [
CreateDocument('Author', collection='author'),
CreateField('Author', 'name', choices=None, db_field='name', default=None, max_length=None,
min_length=None, null=False, primary_key=False, regex=None, required=False,
sparse=False, type_key='StringField', unique=False, unique_with=None),
RenameField('Book', 'name', new_name='caption'),
AlterField('Book', 'caption', required=True, db_field='caption'),
AlterField('Book', 'year', type_key='IntField', min_value=None, max_value=None),
DropField('Book', 'isbn'),
CreateField('Book', 'author', choices=None, db_field='author', dbref=False, default=None,
target_doctype='Author', null=False, primary_key=False, required=False, sparse=False,
type_key='ReferenceField', unique=False, unique_with=None),
]
Metadata
Release files for mongoengine-migrate 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mongoengine-migrate-0.0.3.tar.gz | 76.9 kB | Without provenance | Details |
Release files / mongoengine-migrate-0.0.3.tar.gz
| Download URL | mongoengine-migrate-0.0.3.tar.gz |
|---|---|
| Size | 76.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d20498cdaa56e08cab87211d2c6980c3f1c62518fe4d10d22eea17a8070340ca
|
|
BLAKE2b-256 checksum How to use checksums |
e25115f352c639eb1e4760e1cdae18d0aa4a47c268441b5c9988e197642b1c5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.10
|
Security for mongoengine-migrate 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.