summaryrefslogtreecommitdiff
path: root/db/migrate/20200406132529_add_resource_state_events_table.rb
blob: ce241dff4ddfb9bb8f4ca3a50b2d9b074ce040c6 (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 AddResourceStateEventsTable < ActiveRecord::Migration[6.0]
  DOWNTIME = false

  def change
    create_table :resource_state_events, id: :bigserial do |t|
      t.bigint :user_id, null: false
      t.bigint :issue_id, null: true
      t.bigint :merge_request_id, null: true

      t.datetime_with_timezone :created_at, null: false
      t.integer :state, limit: 2, null: false

      t.index [:issue_id, :created_at], name: 'index_resource_state_events_on_issue_id_and_created_at'
      t.index [:user_id], name: 'index_resource_state_events_on_user_id'
      t.index [:merge_request_id], name: 'index_resource_state_events_on_merge_request_id'
    end
  end
end