Hi, Sorry, I forgot to mention that I've run the first migration script before running "alembic revision --autogenerate" again, so that my DB was up-to-date before creating a new revision.
As to the table "foo", yes, it exists after running the migrations, but it's still being created as an operation in the second migration script. The fact that the migrations have been run is what guaranteed the second migration script to be created successfully. I'll try to put up a dummy project to demonstrate this problem. Thanks, Diogo On Tuesday, February 10, 2015 at 2:23:07 AM UTC-2, Michael Bayer wrote: > > > > Diogo Baeder <diogo...@gmail.com <javascript:>> 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 sqlalchemy-alembic+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.