On Apr 12, 2012, at 10:50 AM, limodou wrote: > On Thu, Apr 12, 2012 at 10:39 PM, Michael Bayer > <mike...@zzzcomputing.com> wrote: >> >> On Apr 12, 2012, at 4:18 AM, limodou wrote: >> >>> I also have other requirements: >>> >>> 1. if there is no changes should it can create nothing, not like this: >>> >>> def upgrade(): >>> ### commands auto generated by Alembic - please adjust! ### >>> pass >>> ### end Alembic commands ### >>> >>> >>> def downgrade(): >>> ### commands auto generated by Alembic - please adjust! ### >>> pass >>> ### end Alembic commands ### >> >> that's what it should be doing what are you getting ? > > But if I changed the database later,
i dont understand, "changed the database" - do you mean, you changed your SQLAlchemy models? or you went into the database directly and manually added things ? > and I want to run revision > command, and it'll tell me the datebase is not up to date. revision with --autogenerate is comparing the current state of the database to the current SQLAlchemy metadata, so the DB has to be on the latest revision for this to work, otherwise it will repeat other migrations that are already in previous version files that haven't been run. why not say "alembic upgrade head" each time before you say "revision --autogenerate" ? > So I must > run upgrade even though that will no effect at all. I'm really not following. How is the version number in alembic_version not the same number in your version files, except that you just need to run "alembic upgrade head" ? > So I think it's > tedious. So I think if there is no change at all, why not just say " > The database is up to date, and don't create any revision file at all. > If is this appoach better? --autogenerate can't detect all changes, though. if you're using the "revision" command, it implies you want it to create a new revision file. It would be quite annoying if I wanted to use --autogenerate to catch things in general before I add my manual migration changes, which could include changes in column type or changes in server default that Alembic by default does not detect. > > So if it can be an option to let user to decide if he want to remove > the head revision will be handful. User knows what they want to do. I > just don't want to delete the file manually. That's asking Alembic to guess, in a dangerous way, what revision files should be deleted. Suppose I check out the latest source tree. Revision files load in, say new files with (fake) numbers 7, 8, and 9 load in. My database is at version 6. For some reason, I'm not running "alembic upgrade head" (why??). I forget to do all that, then I change some of my app, and say "alembic revision -m 'my changes' --autogenerate --delete-everything-not-there" - according to this command, alembic would need to delete *three* revision files, for 7, 8 and 9, which I haven't even looked at. Since the request is really, "delete all revision files down to the most recent revision that's in the database". I can't see people really wanting that behavior without them having to check things manually first. It's a manual operation, and there's no way to automate this - therefore might as well have the user just "rm <the file>" - that's what rm is for ! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.