1 | # frozen_string_literal: true |
||
2 | |||
3 | # Migration to create instruments table |
||
4 | View Code Duplication | class CreateInstruments < ActiveRecord::Migration[5.1] |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
5 | def change |
||
6 | create_table :instruments, comment: 'Instruments table' do |t| |
||
7 | t.string :name, null: false, unique: true, index: true |
||
8 | t.string :version_number, null: false, default: '1.0' |
||
9 | t.string :instrument_type, null: false, default: 'json' |
||
10 | t.jsonb :json_content, null: false, default: '{}' |
||
11 | t.text :csv_content, null: false, index: true, default: '' |
||
12 | t.text :instructions, null: false, default: '' |
||
13 | t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' } |
||
14 | end |
||
15 | |||
16 | add_index :instruments, :json_content, using: :gin, name: 'instrument_json_content' |
||
17 | add_index :instruments, %i[name version_number], unique: true |
||
18 | end |
||
19 | end |
||
20 |