From f7ddd4d09072ef3c483d8bff77da08e7b325cbc4 Mon Sep 17 00:00:00 2001
From: Stan Hu <stanhu@gmail.com>
Date: Tue, 23 Aug 2016 01:19:58 -0700
Subject: [PATCH] Change merge_error column from string to text type

In some cases, the artificial 255-character limit would cause an error in
MergeWorker.

Closes #20593
---
 CHANGELOG                                              |  2 ++
 .../20160823081327_change_merge_error_to_text.rb       | 10 ++++++++++
 db/schema.rb                                           |  4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 db/migrate/20160823081327_change_merge_error_to_text.rb

diff --git a/CHANGELOG b/CHANGELOG
index 0ea728cf89b..ea94cf8781b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,7 @@
 Please view this file on the master branch, on stable branches it's out of date.
+
 v 8.12.0 (unreleased)
+  - Change merge_error column from string to text type
   - Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
 
 v 8.11.0 (unreleased)
diff --git a/db/migrate/20160823081327_change_merge_error_to_text.rb b/db/migrate/20160823081327_change_merge_error_to_text.rb
new file mode 100644
index 00000000000..7920389cd83
--- /dev/null
+++ b/db/migrate/20160823081327_change_merge_error_to_text.rb
@@ -0,0 +1,10 @@
+class ChangeMergeErrorToText < ActiveRecord::Migration
+  include Gitlab::Database::MigrationHelpers
+
+  DOWNTIME = true
+  DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.'
+
+  def change
+    change_column :merge_requests, :merge_error, :text, limit: 65535
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 25cfb5de2fa..802c928b2fc 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 20160819221833) do
+ActiveRecord::Schema.define(version: 20160823081327) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -613,7 +613,7 @@ ActiveRecord::Schema.define(version: 20160819221833) do
     t.integer  "position",                     default: 0
     t.datetime "locked_at"
     t.integer  "updated_by_id"
-    t.string   "merge_error"
+    t.text     "merge_error"
     t.text     "merge_params"
     t.boolean  "merge_when_build_succeeds",    default: false, null: false
     t.integer  "merge_user_id"
-- 
GitLab