On Thu, Apr 12, 2012 at 11:52 PM, Michael Bayer
<mike...@zzzcomputing.com> wrote:
>
> 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 ?

I just changed sqlalchemy models, but not directly change the database.

>
> 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" ?
>
>

Because I think the script will do nothing at all (because the created
script upgrade section is empty), why it'll always keep no use
scripts? Why not just keep the last upgraded script and don't create
new script if there is no changes?

> 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" ?

But if I don't run alembic upgrade head, I can't do other things. And
for a revison control system, if there are no changes at all, it'll
not create any patches at all, and I think maybe this is a good way.

>
> 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.
>

I know, but sometimes user want to create new revision even there is
no changes, but sometime they won't I think. And if there is an option
to toggle the behavior is better.

>
>
> 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??).

For example, in my case, when I made some changes and I want to test
them, so I can run "revision --autogenerate" and "upgrade" the
database. And then I made other changes, and do the cycle again I can
do this way. But sometimes I just change the model and run "revision
--autogenerate" and don't upgrade the database, and I also made other
changes, and I want to merge two changes into one piece, so I just
want to delete the lastest revision, and re autogenerate the revision.
So if the alembic can delete the head revision script for me, I don't
need to delete it manually. That's what I think.

>  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 !
>

But in my case, I can't create 8, 9 before I run "upgrade" on 7, I'm
using autogenerate option, so how to create 8, 9 without upgrade on
previous rerison?  I can only keep on un upgraded revision in my test.

-- 
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: http://code.google.com/p/uliweb/
My Blog: http://hi.baidu.com/limodou

-- 
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.

Reply via email to