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.
From: https://github.com/diogob/activerecord-postgres-hstore just set the following in application.rb:
config.active_record.schema_format = :sql
Now structure.sql will be used instead of schema.rb to create the database from scratch with rake db:reset
or rake db:prepare
and will be specific to PostGres.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With