How to rename a column and change its type by migration same time

后端 未结 4 1446
迷失自我
迷失自我 2021-02-06 23:43

In my general_exams table, I have a column named semester, type is string. Now I want to change its name to semester_id, type

4条回答
  •  广开言路
    2021-02-07 00:06

    This error is because there is existing data in the tables (or default values, perhaps ..) that PG doesn't know how to convert from string to integer. Either get rid of the data or tell PG how you want to convert it, using PG specific SQL (I think you'll want USING) and execute migration command. See Rails guides on migrations.

提交回复
热议问题