summaryrefslogtreecommitdiff
path: root/db/migrate/20200326122700_create_diff_note_positions.rb
blob: d37f7fef07894b097c20263d3eaf42c308239101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

class CreateDiffNotePositions < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  # rubocop:disable Migration/AddLimitToTextColumns
  # rubocop:disable Migration/PreventStrings
  def up
    with_lock_retries do
      create_table :diff_note_positions do |t|
        t.references :note, foreign_key: { on_delete: :cascade }, null: false, index: false
        t.integer :old_line
        t.integer :new_line
        t.integer :diff_content_type, limit: 2, null: false
        t.integer :diff_type, limit: 2, null: false
        t.string :line_code, limit: 255, null: false
        t.binary :base_sha, null: false
        t.binary :start_sha, null: false
        t.binary :head_sha, null: false
        t.text :old_path, null: false
        t.text :new_path, null: false

        t.index [:note_id, :diff_type], unique: true
      end
    end
  end
  # rubocop:enable Migration/PreventStrings
  # rubocop:enable Migration/AddLimitToTextColumns

  def down
    drop_table :diff_note_positions
  end
end