Use PostgreSQL JSON column type with Rails 3

Viewed 4465

The following migration in Rails 3 works:

class CreateUserActions < ActiveRecord::Migration
  def up
    create_table :user_actions do |t|
      t.datetime :time
      t.integer  :user_id
      t.text     :action
      t.column   :details, :json
      t.timestamps
    end
  end

  def down
    drop_table 'user_actions'
  end
end

...but schema.rb is now incomplete reporting

# Could not dump table "user_actions" because of following StandardError
#   Unknown type 'json' for column 'details'

So rake db:reset will fail to create the user_actions table.

1 Answers
Related