diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-11-14 22:18:05 -0800 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-12-01 15:26:41 -0800 |
commit | dd3ba1f200f0d753a1fafc058b4423f230398dce (patch) | |
tree | 55b2f0e900ad11b5af4c8409a3bc7dafc5a6ef4a /db | |
parent | 0e97e3089fba60c3e405f907cbc937cbc1b662ad (diff) | |
download | gitlab-ce-dd3ba1f200f0d753a1fafc058b4423f230398dce.tar.gz |
Fix uploads.path length for long filenames
This will prevent our other migration for adding old files to the uploads table from breaking.
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb | 25 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb b/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb new file mode 100644 index 00000000000..1fbe505f804 --- /dev/null +++ b/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb @@ -0,0 +1,25 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class SetUploadsPathSizeForMysql < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + # We need at least 297 at the moment. For more detail on that number, see: + # https://gitlab.com/gitlab-org/gitlab-ce/issues/40168#what-is-the-expected-correct-behavior + # + # Rails + PostgreSQL `string` is equivalent to a `text` field, but + # Rails + MySQL `string` is `varchar(255)` by default. Also, note that we + # have an upper limit because with a unique index, MySQL has a max key + # length of 3072 bytes which seems to correspond to `varchar(1024)`. + change_column :uploads, :path, :string, limit: 511 + end + + def down + # It was unspecified, which is varchar(255) by default in Rails for MySQL. + change_column :uploads, :path, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index effb2604af2..fed7284a1a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1721,7 +1721,7 @@ ActiveRecord::Schema.define(version: 20171124150326) do create_table "uploads", force: :cascade do |t| t.integer "size", limit: 8, null: false - t.string "path", null: false + t.string "path", limit: 511, null: false t.string "checksum", limit: 64 t.integer "model_id" t.string "model_type" |