Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20201111115414_create_incident_management_oncall_schedules.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dbb7d1c080895f26dabc0cec6e5808c0f1da99b7 (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
33
34
35
36
# frozen_string_literal: true

class CreateIncidentManagementOncallSchedules < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    with_lock_retries do
      unless table_exists?(:incident_management_oncall_schedules)
        create_table :incident_management_oncall_schedules do |t|
          t.timestamps_with_timezone
          t.references :project, index: true, null: false, foreign_key: { on_delete: :cascade }
          t.integer :iid, null: false
          t.text :name, null: false
          t.text :description
          t.text :timezone

          t.index %w(project_id iid), name: 'index_im_oncall_schedules_on_project_id_and_iid', unique: true, using: :btree
        end
      end
    end

    add_text_limit :incident_management_oncall_schedules, :name, 200
    add_text_limit :incident_management_oncall_schedules, :description, 1000
    add_text_limit :incident_management_oncall_schedules, :timezone, 100
  end

  def down
    with_lock_retries do
      drop_table :incident_management_oncall_schedules
    end
  end
end