使用" BIGINT UNSIGNED"在Rails的架构/活动记录 [英] Using "BIGINT UNSIGNED" in Rails schema / Active Record
问题描述
我有一个Rails应用程序,需要能够保存文件的指纹在一个MySQL数据库。这些指纹是填写一个BIGINT的齐全,甚至需要未签约的额外空间号码。我不能使用VARCHAR因为数学操作需要在数据库端以后进行。
I have a Rails-application that needs to be able to save fingerprints of files in a mysql-database. These fingerprints are numbers that fill the complete range of a BIGINT and even need to extra space of UNSIGNED. I can't use a "VARCHAR" since a mathematic-operation needs to be performed on the database-side later on.
所以,我创建了我的表列如下所示:
So I created my table-columns like so:
t.column :fingerprint, 'BIGINT UNSIGNED'
作品般的魅力。
但运行时,
rake db:reset
我总是得到一个schema.rb包括:
I always get a schema.rb that includes:
t.integer "fingerprint", :limit => 8
手动编辑为BIGINT未签约的作品,但被立即更换,当我运行耙分贝:重置了。
Manually editing to "BIGINT UNSIGNED" works but is immediately replaced, when I run "rake db:reset" again.
有没有办法让这个永久复位的?
Is there any way to make this persistent between resets?
推荐答案
解决的办法很简单。如果您将您的应用程序的模式格式:SQL一切都应该按预期工作
The solution is quite simple. If you set the schema format of your application to :sql everything should work as expected.
修改配置/ application.rb中
并进行以下更改/添加:
Edit your config/application.rb
and make the following change/addition:
config.active_record.schema_format =:SQL
config.active_record.schema_format = :sql
您可以在导轨导向更详细的解释: HTTP: //guides.rubyonrails.org/migrations.html#types-of-schema-dumps
You can find a more detailed explanation in the rails guide: http://guides.rubyonrails.org/migrations.html#types-of-schema-dumps
这篇关于使用" BIGINT UNSIGNED"在Rails的架构/活动记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!