0

The Alembic API has an alter_column method on the migration context object (https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.alter_column). However, when I tried to alter a column type of a column that contains data Oracle responded with "ORA-01439: column to be modified must be empty to change datatype".

How should I use the Alembic API in order to alter a column type, which contains data?

E.g., change the column type from date to varchar.

stackhatter
  • 304
  • 2
  • 11

1 Answers1

0
  1. If you are using oracle 11g & onward then you can go for virtual column
  2. create new column with required datatype, update it's data with old column's data, delete old column, rename new column with old column name
Poonam Adhav
  • 382
  • 3
  • 10