2016-09-02 27 views
0

我已經digging around看我怎麼能有我所有的新和後續的型號標識的有8個字節的限制。解答顯示如何添加一個新的表格列;我希望每當我創建一個新的Model時,它會自動擁有一個8字節的limit。可能?加載ActiveModel增加ID至8字節

當創建一個新的模式,我得到:

ActiveModel::RangeError: 36565651767 is out of range for ActiveModel::Type::Integer with limit 4

凡從4此限制更改爲8?

回答

0

一個possible duplicate,但因爲會有誤差:

you can't redefine the primary key column 'id'. To define a custom primary key, pass { id: false } to create_table.

這意味着你的表應該是這樣的:

class MyModels < ActiveRecord::Migration[5.0] 
    def change 
    create_table :my_models, {id: false } do |t| 
     t.column :id, limit: 8 
     ... 
    end 
    end 
end 
相關問題