diff options
Diffstat (limited to 'db/migrate/20201125233219_add_incident_management_on_call_participants.rb')
-rw-r--r-- | db/migrate/20201125233219_add_incident_management_on_call_participants.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/20201125233219_add_incident_management_on_call_participants.rb b/db/migrate/20201125233219_add_incident_management_on_call_participants.rb new file mode 100644 index 00000000000..2a9b1d8b276 --- /dev/null +++ b/db/migrate/20201125233219_add_incident_management_on_call_participants.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class AddIncidentManagementOnCallParticipants < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + PARTICIPANT_ROTATION_INDEX_NAME = 'index_inc_mgmnt_oncall_participants_on_oncall_rotation_id' + PARTICIPANT_USER_INDEX_NAME = 'index_inc_mgmnt_oncall_participants_on_oncall_user_id' + UNIQUE_INDEX_NAME = 'index_inc_mgmnt_oncall_participants_on_user_id_and_rotation_id' + + disable_ddl_transaction! + + def up + unless table_exists?(:incident_management_oncall_participants) + with_lock_retries do + create_table :incident_management_oncall_participants do |t| + t.references :oncall_rotation, index: false, null: false, foreign_key: { to_table: :incident_management_oncall_rotations, on_delete: :cascade } + t.references :user, index: false, null: false, foreign_key: { on_delete: :cascade } + t.integer :color_palette, limit: 2, null: false + t.integer :color_weight, limit: 2, null: false + t.index :user_id, name: PARTICIPANT_USER_INDEX_NAME + t.index :oncall_rotation_id, name: PARTICIPANT_ROTATION_INDEX_NAME + t.index [:user_id, :oncall_rotation_id], unique: true, name: UNIQUE_INDEX_NAME + end + end + end + end + + def down + drop_table :incident_management_oncall_participants + end +end |