开发者

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

开发者 https://www.devze.com 2022-12-30 23:59 出处:网络
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.

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 th开发者_Go百科ing 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
0

精彩评论

暂无评论...
验证码 换一张
取 消