8

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 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Nice! I didn't even know this was possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.