Coder Social home page Coder Social logo

Comments (2)

klen avatar klen commented on May 30, 2024

You shouldn't do it. Yes, the lib runs old migration again but in "fake" mode. The lib needs do this for creation of "virtual" time models, the virtual models are using for "--auto" migrations and inside migration' scripts for data migrations. If you have a data migration, you should use something like this:

WRONG! DONT DO THIS!

from mymodels import MyModel

def migrate(migrator, database, fake=false, **kwargs):
     """Update something in db."""
    for obj in MyModel.select():
         obj.field = 'a new value'

RIGHT WAY:

def migrate(migrator, database, fake=false, **kwargs):
     """Update something in db."""
    MyModel = migrator.orm['mymodel']  # Return virtual model in current migration state
    for obj in MyModel.select():
         obj.field = 'a new value'

from peewee_migrate.

tuukkamustonen avatar tuukkamustonen commented on May 30, 2024

Oh. That hits me as a big inconvenience, and having to dig the models from Migrator sounds quite weird - I'm sure you got the technical reasoning for it, but is there room for improvement?

At least it should be documented.

from peewee_migrate.

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.