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

class CreateCiRef < ActiveRecord::Migration[5.2]
  DOWNTIME = false

  def change
    create_table :ci_refs do |t|
      t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }, type: :integer
      t.integer :lock_version, default: 0
      t.integer :last_updated_by_pipeline_id
      t.boolean :tag, default: false, null: false
      t.string :ref, null: false, limit: 255
      t.string :status, null: false, limit: 255
      t.foreign_key :ci_pipelines, column: :last_updated_by_pipeline_id, on_delete: :nullify
      t.index [:project_id, :ref, :tag], unique: true
      t.index [:last_updated_by_pipeline_id]
    end
  end
end