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

class CreateCiTestCaseFailures < ActiveRecord::Migration[6.0]
  DOWNTIME = false

  def up
    create_table :ci_test_case_failures do |t|
      t.datetime_with_timezone :failed_at
      t.bigint :test_case_id, null: false
      t.bigint :build_id, null: false

      t.index [:test_case_id, :failed_at, :build_id], name: 'index_test_case_failures_unique_columns', unique: true, order: { failed_at: :desc }
      t.index :build_id
      t.foreign_key :ci_test_cases, column: :test_case_id, on_delete: :cascade
      # NOTE: FK for ci_builds will be added on a separate migration as per guidelines
    end
  end

  def down
    drop_table :ci_test_case_failures
  end
end