-
-
Notifications
You must be signed in to change notification settings - Fork 252
(PG) Support ALTER COLUMN TYPE USING #626
Copy link
Copy link
Closed
Description
Motivation
Currently it is not possible in migrations to add a USING clause to changing the column type that have no direct available cast, without the use of writing SQL queries myself. The example that I happened to come across myself is changing the type of a column from bigint to bigint[] (array).
The postgres query to achieve this is as follows:
ALTER TABLE table_name ALTER column_name TYPE bigint[] USING array[column_name];Proposed Solutions
Something like:
manager.alter_table(
Table::alter()
.table(type::Table)
.modify_column(ColumnDef::new(type::ColumnName).array(Type::BigInteger, SimpleExpr::Using(type::ColumnName)))
.to_owned());Additional Information
I was requested to open this issue in a Discord thread titled "(PG) Change type of column to array of the previous type."
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels