the "existing type" comes from what is reflected from the database and
your custom type is not automatically reflectable.
The "existing type" for a PG alter_column is not important here because
Postgresql's "ALTER COLUMN" doesn't require it. It's mostly for MySQL
and SQL Server that "existing type" is important.
If you want to get your type in there without just manually changing it
(which is the usual approach for edge cases like these) you'd need to
build an event handler that populates it into the column metadata (the
SQLA column_reflect event usually is where this is). SQLAlchemy
doesn't yet have very good hooks for custom type reflection, though so
this is not that straightforward (you'd need to re-load the type
information for each column to detect if your type is there).
On 06/08/2016 03:21 AM, Brian Ogollah wrote:
I am creating custom types in sqlalchemy to handle postgresql composite
types. The first time i run the migrations, alembic discovers the types
but after adding changes e.g cardinality from nullable=True ---->
nullable=False, alembic assigns a NullType to my custom types. what is
the issues here and how can i fix it?
def upgrade():
### commands auto generated by Alembic - please adjust! ##
op.alter_column('organization', 'active',
existing_type=sa.BOOLEAN(),
nullable=False)
op.alter_column('organization', 'identifier',
existing_type=sa.NullType(),
nullable=False)
op.alter_column('organization', 'name',
existing_type=sa.TEXT(),
nullable=False)
### end Alembic commands ###
--
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.