Skip to content

Instantly share code, notes, and snippets.

@typeoneerror
Created July 20, 2011 21:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typeoneerror/1095974 to your computer and use it in GitHub Desktop.
Save typeoneerror/1095974 to your computer and use it in GitHub Desktop.
Hacking in bigint support for Mysql and Postgresql. Got a better method?
# Load the rails application
require File.expand_path('../application', __FILE__)
require 'active_record/connection_adapters/mysql2_adapter'
require 'active_record/connection_adapters/postgresql_adapter'
ActiveRecord::ConnectionAdapters::Mysql2Adapter::NATIVE_DATABASE_TYPES[:big_primary_key] = "BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY".freeze
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:big_primary_key] = "bigserial primary key".freeze
# Initialize the rails application
Ou1::Application.initialize!
@zhuangsirui
Copy link

Hi, I try this solution, but when I run rake db:migrate, Error thourghed like this

undefined method `uuid' for #<ActiveRecord::ConnectionAdapters::TableDefinition

I found rake task hasnot load the environment.rb file.

Am i do wrong?
Thx!

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