On Thu, Apr 12, 2012 at 10:37 PM, Michael Bayer
<mike...@zzzcomputing.com> wrote:
>
> On Apr 12, 2012, at 4:07 AM, limodou wrote:
>
>> I'm using alembic today, and I found a problem, if I changed the
>> column, it'll automatically create add and drop statment, just like
>> this:
>>
>>    op.add_column('bas_grp_user', sa.Column('username', sa.Integer(),
>> nullable=False))
>>    op.drop_column('bas_grp_user', u'USERNAME')
>>
>> But when I ran the upgrade I got:
>>
>> sqlalchemy.exc.OperationalError: (OperationalError) (1060, "Duplicate
>> column name 'username'") 'ALTER TABLE bas_grp_user ADD COLUMN username
>> INTEGER NOT NULL' ()
>
> this is a column name change - per the documentation, Alembic can't detect 
> these and you need to manually change it to an alter_column().    In this 
> case, there seems to be an odd casing change where the DB is reporting the 
> name as USERNAME in all caps (usually this is oracle or firebird, though 
> alembic should be normalizing these to lowercase....) - but then the database 
> can't distinguish between USERNAME and "username".    If this is happening 
> for all your columns then there might be some dialect-related issue at play.  
> Otherwise, if you just changed the name to "USERNAME" in the DB with quotes 
> then this is what you'd get.
>

I defined the column name as "USERNAME“ at first, then I changed it to
"username", so it is the thing I want to change. I know the doc says
it can't detect the column rename, but I think if alembic can put drop
statement before add statement, it'll ok for this situation. What do
you think?

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