On 12/11/2015 04:39 PM, Ofir Herzas wrote: > Hi Mike, > I've just checked my code and I noticed that I already use existing_type > (not sure what was wrong with the documentation in that aspect). > > Can you elaborate a bit on specifying custom rules as you mentioned? > I tried issuing a drop_constraint before calling the alter_column but > that doesn't stop alter_column from trying to remove the check > constraint by itself, leading to the same exception. > On the other hand, I didn't see any parameter in the alter_column method > that accepts a constraint name
You can call the drop_constraint(), then when you do the alter_column, inside the existing_type put "create_constraint=False", so that it sees it as an un-constrainted type. drop_contraint('constraint_name') alter_column('table', 'column', type=NewType(), existing_type=Boolean(create_constraint=False)) > > Thanks, > Ofir > > > On Thursday, December 10, 2015 at 3:39:42 PM UTC+2, Ofir Herzas wrote: > > I'm trying to run an alter_column operation from a Boolean type > column to SmallInteger on Oracle. > > According to the documentation: "...Type changes which are against > the SQLAlchemy “schema” types |Boolean| > > <http://www.sqlalchemy.org/docs/core/type_basics.html#sqlalchemy.types.Boolean> > and |Enum| > > <http://www.sqlalchemy.org/docs/core/type_basics.html#sqlalchemy.types.Enum> > may > also add or drop constraints which accompany those types on backends > that don’t support them natively. > The |existing_server_default| argument is used in this case as well > to remove a previous constraint...." > > Does this mean that the alter column should work out-of-the-box or > do I have to remove the constraint myself because I'm getting the > following error on alembic 0.8.3 (sqlalchemy 1.0.9): > > | > sqlalchemy.exc.CompileError:Can't emit DROP CONSTRAINT for > constraint CheckConstraint(<sqlalchemy.sql.elements.BinaryExpression > object at 0x28a9b10>, name='_unnamed_', table=Table('t_message', > MetaData(bind=None), Column('is_bulletin', Boolean(), > table=<t_message>), schema=None), > _create_rule=<sqlalchemy.util.langhelpers.portable_instancemethod > object at 0x289ac68>, _type_bound=True); it has no name > | > > > And on a previous version (alembic 0.6.5, sqlalchemy 0.9.7) I got > the following error: > > | > sqlalchemy.exc.DatabaseError:(DatabaseError)ORA-02443:Cannotdrop > constraint -nonexistent constraint > 'ALTER TABLE t_message DROP CONSTRAINT None'{} > | > > > Your help will be appreciated... > > -- > 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 > <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout. -- 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.