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