Skip to content

Instantly share code, notes, and snippets.

@will
Created February 17, 2016 18:31
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save will/dc5c29df31a929d69668 to your computer and use it in GitHub Desktop.
Save will/dc5c29df31a929d69668 to your computer and use it in GitHub Desktop.
proper postgres types for rails
# config/initializers/postgres_types.rb
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.tap do |t|
t[:primary_key] = "bigserial primary key"
t[:datetime] = "timestamptz"
t[:timestamp] = "timestamptz"
t[:string] = "text"
end
@csuhta
Copy link

csuhta commented Feb 26, 2016

I was playing around with this, and I had to change it to:

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.tap do |t|
  t[:primary_key] = {name:"bigserial primary key"}
  t[:datetime] = {name:"timestamptz"}
  t[:timestamp] = {name:"timestamptz"}
  t[:string] = {name:"text"}
end

in Rails 4.2 because rake db:* tasks were choking on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment