Commit ba00458a authored by Oswaldo Ferreira's avatar Oswaldo Ferreira
Browse files

Add multi-line suggestion migrations

Adds outdated, lines_above and lines_below columns to
suggestions table.

outdated - boolean which represents whether the suggestion
is outdated or not. For instance, if any line changed after
you left the multi-line suggestion, even though the note
is not outdated, it helps tracking if the content has changed
in the latest file. We cache this information in a column given
it's not a cheap operation to do for every suggestion in the
request time.
lines_below, lines_above - persists the parsed arguments from
`suggestion:-10+3` syntax, where `10` would be lines_above and
3 lines_below. We need that to dynamically calculate which
lines we should monitor for outdating / persisting the correct
content in from_content column.
parent 61e0e4728598
# frozen_string_literal: true
class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false
add_column_with_default :suggestions, :lines_above, :integer, default: 0, allow_null: false
add_column_with_default :suggestions, :lines_below, :integer, default: 0, allow_null: false
end
def down
remove_columns :suggestions, :outdated, :lines_above, :lines_below
end
end
...@@ -2039,6 +2039,9 @@ ...@@ -2039,6 +2039,9 @@
t.string "commit_id" t.string "commit_id"
t.text "from_content", null: false t.text "from_content", null: false
t.text "to_content", null: false t.text "to_content", null: false
t.boolean "outdated", default: false, null: false
t.integer "lines_above", default: 0, null: false
t.integer "lines_below", default: 0, null: false
t.index ["note_id", "relative_order"], name: "index_suggestions_on_note_id_and_relative_order", unique: true, using: :btree t.index ["note_id", "relative_order"], name: "index_suggestions_on_note_id_and_relative_order", unique: true, using: :btree
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment