Rails Migration changing column to use Postgres arrays

后端 未结 5 1648
故里飘歌
故里飘歌 2020-12-14 03:28

I am trying to change a column in my database so that it can use the Postgres array data type. Currently the table column is of type string.

I am using the following

5条回答
  •  猫巷女王i
    2020-12-14 03:53

    def change
    
        change_column :table, :dummy_column, :string, array: true, default: '{}'
    
    end
    

    Notice:

    it's specified as data type :string with array: true to default the column to an empty array ( [] ), you use default: '{}'

提交回复
热议问题