diff options
author | Drew Blessing <drew@gitlab.com> | 2016-09-13 17:15:14 -0500 |
---|---|---|
committer | Drew Blessing <drew@gitlab.com> | 2016-09-15 21:59:58 -0500 |
commit | e000f02bd3b7c13f7f3a95b855fea6b3dd277417 (patch) | |
tree | 65443e940c4f319f74d98e8eb89a11988d9e697f /doc/development | |
parent | 1038ef54d0405ae08eb3f413f936197f0775987b (diff) | |
download | gitlab-ce-e000f02bd3b7c13f7f3a95b855fea6b3dd277417.tar.gz |
Add support for column limits in add_column_with_default
Diffstat (limited to 'doc/development')
-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. |