简体   繁体   中英

How to use bigint data type for primary keys in Rails 2.3 using activerecord-jdbc

I have a Rails app that I'm porting from Rails 1.2 to 2.3. I'm also moving from the Ruby MRI to the latest version of JRuby as well.

In the existing (Rails 1.2) app I use the mysql_bigint plugin to provide support for 64-bit ints as primary keys.

I need to to the same thing for the new application running against a MS SQL 2005 database server.

I'm not sure if the snippet here would help: using UUID as primary key in rails and polymorph relationships

Any ideas where to start?

TIA

Dave

Add this to config/environment.rb:

module JdbcSpec
  module MsSQL
    def modify_types(tp)
      super(tp)
      tp[:primary_key] = "bigint NOT NULL IDENTITY(1, 1) PRIMARY KEY"
      tp
    end
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM