diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-09-16 10:44:03 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-09-16 10:44:03 +0000 |
commit | 16da82f441046884dc318bc1829777cc19b444fe (patch) | |
tree | fea72976778ed7b408aa0e25e355bacf26b5098f /doc | |
parent | 7ac475164f06d40b7f33f2f9c663806fa675f462 (diff) | |
parent | 1f399fe437abc67e3f6d4812bab17f0ef0aab77b (diff) | |
download | gitlab-ce-16da82f441046884dc318bc1829777cc19b444fe.tar.gz |
Merge branch 'integer_migration_style' into 'master'
Integer migration style
See merge request !6334
Diffstat (limited to 'doc')
-rw-r--r-- | doc/development/migration_style_guide.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md index b8fab3aaff7..295eae0a88e 100644 --- a/doc/development/migration_style_guide.md +++ b/doc/development/migration_style_guide.md @@ -111,6 +111,28 @@ class MyMigration < ActiveRecord::Migration end ``` + +## Integer column type + +By default, an integer column can hold up to a 4-byte (32-bit) number. That is +a max value of 2,147,483,647. Be aware of this when creating a column that will +hold file sizes in byte units. If you are tracking file size in bytes this +restricts the maximum file size to just over 2GB. + +To allow an integer column to hold up to an 8-byte (64-bit) number, explicitly +set the limit to 8-bytes. This will allow the column to hold a value up to +9,223,372,036,854,775,807. + +Rails migration example: + +``` +add_column_with_default(:projects, :foo, :integer, default: 10, limit: 8) + +# or + +add_column(:projects, :foo, :integer, default: 10, limit: 8) +``` + ## Testing Make sure that your migration works with MySQL and PostgreSQL with data. An empty database does not guarantee that your migration is correct. |