Code Duplication    Length = 11-14 lines in 4 locations

db/migrate/20180306215113_create_study_events.rb 1 location

@@ 4-16 (lines=13) @@
1
# frozen_string_literal: true
2
3
# Table to represent study events in an arm
4
class CreateStudyEvents < ActiveRecord::Migration[5.1]
5
  def change
6
    create_table :study_events do |t|
7
      t.string :name, null: false, index: true
8
      t.integer :order, null: false, index: true, default: 1
9
      t.references :arm, null: false, foreign_key: true, index: true 
10
      t.datetime :event_date, null: false, default: -> { 'CURRENT_TIMESTAMP' }
11
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
12
    end
13
14
    add_index :study_events, %i[arm_id name], unique: true, name: 'index_by_arm_name'
15
  end
16
end
17

db/migrate/20180311033124_create_survey_participants.rb 1 location

@@ 4-14 (lines=11) @@
1
# frozen_string_literal: true
2
3
# Creates tables for association class between participants and surveys
4
class CreateSurveyParticipants < ActiveRecord::Migration[5.1]
5
  def change
6
    create_table :survey_participants do |t|
7
      t.references :participant, null: false, foreign_key: true
8
      t.references :survey, null: false, foreign_key: true
9
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
10
    end
11
12
    add_index :survey_participants, %i[participant_id survey_id], unique: true, name: 'index_by_participant_survey'
13
  end
14
end
15

db/migrate/20180227035049_create_assessment_instruments.rb 1 location

@@ 4-17 (lines=14) @@
1
# frozen_string_literal: true
2
3
# Creates table for association class between assessments and instruments
4
class CreateAssessmentInstruments < ActiveRecord::Migration[5.1]
5
  def change
6
    create_table :assessment_instruments do |t|
7
      t.references :assessment, null: false, foreign_key: true
8
      t.references :instrument, null: false, foreign_key: true
9
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
10
    end
11
12
    add_index :assessment_instruments, 
13
              %i[assessment_id instrument_id], 
14
              unique: true,
15
              name: 'index_by_assessment_instrument'
16
  end
17
end
18

db/migrate/20180304030326_create_scores.rb 1 location

@@ 4-15 (lines=12) @@
1
# frozen_string_literal: true
2
3
# Migration to add assessment scores table
4
class CreateScores < ActiveRecord::Migration[5.1]
5
  def change
6
    create_table :scores, comment: 'Scores table' do |t|
7
      t.references :assessment, null: false, index: true
8
      t.string :name, null: false, index: true
9
      t.integer :score, null: false, default: 0
10
      t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
11
    end
12
13
    add_index :scores, %i[assessment_id name], unique: true, name: 'index_by_assessment_name'
14
  end
15
end
16