Giter VIP home page Giter VIP logo

Comments (2)

erny avatar erny commented on July 21, 2024

I have implemented some naif migration system (currently only forward migrations) just creating a collection with the already executed migration steps and running the new ones. All migration steps are python scripts with name: <date_time>_<number>_<description> which are loaded with "exec" and have a "forward" function and a "backward" function and receive as first argument the database, e.g.:

async def forward(db):
    await db.registry_entry.update_many(
        {}, {
            "$rename": {
                "interesteds": "interested_list",
                "signers": "signer_list",
                "attachments": "attachment_list",
            }
        },
    )


async def backward(db):
    pass

This runs automatically on startup. To avoid double execution (with several worker processes) I use an exclusive file lock that allows just one process / thread to execute migrations (and index creation).

So, perhaps, I would consider it out of scope. There are already migration systems for mongodb, both Python or MongoDB. You could also pipe scripts to mongoshell.

from odmantic.

art049 avatar art049 commented on July 21, 2024

Yes, this is a bit out of scope since Migration would typically give you access to the DB driver directly, and thus building migrations directly with ODMantic could be complicated (fetching multiple revisions of the same model).

In the meantime, you can use https://github.com/stxnext/pymongo-migrate or https://github.com/DoubleCiti/mongodb-migrations working both with pymongo.

from odmantic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.