Diogo Baeder <[email protected]> wrote:
> Hi, > > In a project I'm working on, I'm using "alembic revision --autogenerate" so > that it generates my migration scripts based on the models I have; however, > even if I've already generated a migration script which already has the > operation for a certain model (let's call it "Foo"), when I run "alembic > revision --autogenerate" again after creating a "Bar" model it creates a new > migration script (based on the first one as its "down_revision") which also > contains the same operation as the first migration script. In other words, > the second migration script has both the operation from the first script and > the new intended operation. > > Is this an intended behavior? If so, is there a way to tell alembic to > autogenerate only for the missing operations that are needed for the database > to be up-to-date? it should not be possible to run “autogenerate” on a target set of migrations if there is a migration that’s not applied to the database. You will get the error "Target database is not up to date.” Assuming the migrations have been run, then the table from “foo” will exist in the database and it won’t show up as being created in the second migration script. Beyond that, if there’s something strange about the operations we’re talking about here, autogenerate might not have enough information to see that something already exists, but that isn’t typical, would need much more detail. -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
