CreateStudyEventInstruments.change()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
1
# frozen_string_literal: true
2
3
# Creates table for association class between study_events and instruments
4 View Code Duplication
class CreateStudyEventInstruments < ActiveRecord::Migration[5.1]
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5
  def change
6
    create_table :study_event_instruments do |t|
7
      t.references :study_event, null: false
8
      t.references :instrument, null: false
9
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
10
    end
11
12
    add_index :study_event_instruments, %i[study_event_id instrument_id], \
13
              unique: true, name: 'index_by_study_event_instrument' 
14
    add_foreign_key :study_event_instruments, :study_events
15
    add_foreign_key :study_event_instruments, :instruments
16
  end
17
end
18