summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-04 17:41:04 -0500
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 17:44:14 +0100
commit63c7801e459d7a7c3ca5a1222496b8cc188d9258 (patch)
tree90c4aa7b6740e25cf4a2fa0cf229a508d00fe450 /app/models
parentc319f2114177f011cd0c6c23b04f7c19971268bf (diff)
downloadgitlab-ce-63c7801e459d7a7c3ca5a1222496b8cc188d9258.tar.gz
Remove and ignore notes.original_discussion_id column
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/ignorable_column.rb28
-rw-r--r--app/models/note.rb3
2 files changed, 31 insertions, 0 deletions
diff --git a/app/models/concerns/ignorable_column.rb b/app/models/concerns/ignorable_column.rb
new file mode 100644
index 00000000000..eb9f3423e48
--- /dev/null
+++ b/app/models/concerns/ignorable_column.rb
@@ -0,0 +1,28 @@
+# Module that can be included into a model to make it easier to ignore database
+# columns.
+#
+# Example:
+#
+# class User < ActiveRecord::Base
+# include IgnorableColumn
+#
+# ignore_column :updated_at
+# end
+#
+module IgnorableColumn
+ extend ActiveSupport::Concern
+
+ module ClassMethods
+ def columns
+ super.reject { |column| ignored_columns.include?(column.name) }
+ end
+
+ def ignored_columns
+ @ignored_columns ||= Set.new
+ end
+
+ def ignore_column(name)
+ ignored_columns << name.to_s
+ end
+ end
+end
diff --git a/app/models/note.rb b/app/models/note.rb
index 6cb9e84ce26..49ba4ad3f2e 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -9,6 +9,9 @@ class Note < ActiveRecord::Base
include CacheMarkdownField
include AfterCommitQueue
include ResolvableNote
+ include IgnorableColumn
+
+ ignore_column :original_discussion_id
cache_markdown_field :note, pipeline: :note