weixin_39890652 2020-11-20 22:03
浏览 0

Add support for a USING clause when altering a column's type in PostgreSQL

Migrated issue, originally created by Wouter Bolsterlee ()

When changing a column's type, it is sometimes necessary to specify how to convert the existing value into a value of the new type. This is done using the USING clause of the SET DATA TYPE clause of the ALTER TABLE statement. See http://www.postgresql.org/docs/9.4/static/sql-altertable.html for details.

Currently it seems impossible to specify the USING clause using Alembic's op. alter_column(). It would be great if something like alter_column(using="convert_from(data, 'utf-8')::jsonb") would work.

该提问来源于开源项目:sqlalchemy/alembic

  • 写回答

5条回答 默认 最新

  • weixin_39890652 2020-11-20 22:03
    关注

    Michael Bayer () wrote:

    it would be called postgresql_using. I can accept this as a PR which would alter the alembic/ddl/postgresql.py dialect to support this flag, in a similar way as something like "mssql_drop_foreign" in alembic/ddl/mssql.py.

    评论

报告相同问题?