首页 > 代码库 > migration integer limit option

migration integer limit option

 

https://gist.github.com/stream7/1069589

 

:limit        Numeric Type    Column Size    Max value1             tinyint           1 byte        1272             smallint          2 bytes       327673             mediumint         3 byte        8388607nil, 4, 11    int(11)           4 byte        21474836475..8          bigint            8 byte        9223372036854775807

 

关于sequence 字段
limit: 2 是两个字节,16 位,2 的 15 次方是 32767

class CreateTableSubjections < ActiveRecord::Migration[5.0]  def change    create_table :table_subjections do |t|       t.belongs_to :subject, index: true      t.belongs_to :video, index: true      t.string :title, limit: 40      t.string :sub_title, limit: 40      t.string :description, limit: 500      t.integer :status, limit: 1      t.integer :sequence, limit: 2      t.timestamps    end   end end

 

migration integer limit option