summaryrefslogtreecommitdiff
path: root/db/migrate/20181123144235_create_suggestions.rb
blob: 1723f6de7eb500e03c61bdf34d35c33943712c06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class CreateSuggestions < ActiveRecord::Migration[5.0]
  DOWNTIME = false

  def change
    create_table :suggestions, id: :bigserial do |t|
      t.references :note, foreign_key: { on_delete: :cascade }, null: false
      t.integer :relative_order, null: false, limit: 2
      t.boolean :applied, null: false, default: false
      t.string :commit_id
      t.text :from_content, null: false
      t.text :to_content, null: false

      t.index [:note_id, :relative_order],
        name: 'index_suggestions_on_note_id_and_relative_order',
        unique: true
    end
  end
end