Online migration crashes when changing type from Text to REAL #866
Answered
by
zzzeek
Bechma
asked this question in
Usage Questions
-
Describe the bug with this configuration: def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix="sqlalchemy.",
poolclass=pool.NullPool
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
include_schemas=True,
compare_server_default=True,
compare_type=True,
)
with context.begin_transaction():
context.run_migrations() Expected behavior To Reproduce import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '36a16b8bc992'
down_revision = '58e041e2c164'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('t1', 'p1',
existing_type=sa.TEXT(),
type_=sa.REAL(),
existing_nullable=True,
schema='s1')
op.alter_column('t1', 'p1',
existing_type=sa.TEXT(),
type_=sa.REAL(),
existing_nullable=True,
schema='s2')
op.alter_column('t1', 'p1',
existing_type=sa.TEXT(),
type_=sa.REAL(),
existing_nullable=True,
schema='s3')
op.alter_column('t1', 'p1',
existing_type=sa.TEXT(),
type_=sa.REAL(),
existing_nullable=True,
schema='s4')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('t1', 'p1',
existing_type=sa.REAL(),
type_=sa.TEXT(),
existing_nullable=True,
schema='s4')
op.alter_column('t1', 'p1',
existing_type=sa.REAL(),
type_=sa.TEXT(),
existing_nullable=True,
schema='s3')
op.alter_column('t1', 'p1',
existing_type=sa.REAL(),
type_=sa.TEXT(),
existing_nullable=True,
schema='s2')
op.alter_column('t1', 'p1',
existing_type=sa.REAL(),
type_=sa.TEXT(),
existing_nullable=True,
schema='s1')
# ### end Alembic commands ### Error
Versions.
Additional context Have a nice day! |
Beta Was this translation helpful? Give feedback.
Answered by
zzzeek
Jun 16, 2021
Replies: 1 comment 2 replies
-
hey there - PG's USING is supported using postgresql_using: op.alter_column('t1', 'p1',
existing_type=sa.TEXT(),
type_=sa.REAL(),
existing_nullable=True,
schema='s1',
postgresql_using='"p1"::real') |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Bechma
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey there -
PG's USING is supported using postgresql_using: