summaryrefslogtreecommitdiff
path: root/db/migrate/20210813111909_create_ci_build_trace_metadata.rb
blob: d8b7fd656e03ba17075631ed4b53fbb366596f63 (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
# frozen_string_literal: true

class CreateCiBuildTraceMetadata < ActiveRecord::Migration[6.1]
  include Gitlab::Database::MigrationHelpers

  def up
    with_lock_retries do
      create_table :ci_build_trace_metadata, id: false, if_not_exists: true do |t|
        t.references :build,
          index: false,
          primary_key: true,
          default: nil,
          foreign_key: { to_table: :ci_builds, on_delete: :cascade },
          type: :bigint,
          null: false

        t.bigint :trace_artifact_id
        t.integer :archival_attempts, default: 0, null: false, limit: 2
        t.binary :checksum
        t.binary :remote_checksum

        t.index :trace_artifact_id
      end
    end
  end

  def down
    with_lock_retries do
      drop_table :ci_build_trace_metadata, if_exists: true
    end
  end
end