Rails migration to change column type from text to json (Postgresql)
问题 I've been trying unsuccessfully to change a column type in my Postgres database from text to json. Here's what I've tried... class ChangeNotesTypeInPlaces < ActiveRecord::Migration[5.0] def up execute 'ALTER TABLE places ALTER COLUMN notes TYPE json USING (notes::json)' end def down execute 'ALTER TABLE places ALTER COLUMN notes TYPE text USING (notes::text)' end end Also... class ChangeNotesTypeInPlaces < ActiveRecord::Migration[5.0] def up change_column :places, :notes, 'json USING CAST