Rails Migration to convert string to integer?

Don’t drop the column, use this

change_column :table_name, :column_name, 'integer USING CAST(column_name AS integer)'

The “hint” you got from PostgreSQL basically tells you that you need to confirm you want this to happen, and how data should be converted. To confirm the changes, use the block above in your migration

Leave a Comment

tech