Sha256: dd8903f1b35a6c371a84f3f4adddb7e06527900d39cf971fec61241ff941a1eb
Contents?: true
Size: 1.42 KB
Versions: 171
Compression:
Stored size: 1.42 KB
Contents
class CreateHDDiarySlots < ActiveRecord::Migration[5.1] def change create_table :hd_diary_slots do |t| t.integer :diary_id, null: false, index: true t.integer :station_id, null: false, index: true t.integer :day_of_week, null: false, index: true t.integer :diurnal_period_code_id, null: false, index: true t.references :patient, null: false, foreign_key: true, index: true t.integer :updated_by_id, null: false, index: true t.integer :created_by_id, null: false, index: true t.datetime :deleted_at, index: true t.timestamps null: false end # Add CHECK constraint to ensure week and year are in valid ranges reversible do |direction| direction.up do execute <<-SQL ALTER TABLE hd_diary_slots ADD CONSTRAINT day_of_week_in_valid_range CHECK (day_of_week >= 1 AND day_of_week <= 7); SQL end direction.down do execute <<-SQL ALTER TABLE hd_diary_slots DROP CONSTRAINT day_of_week_in_valid_range; SQL end end add_foreign_key :hd_diary_slots, :hd_stations, column: :station_id add_foreign_key :hd_diary_slots, :hd_diaries, column: :diary_id add_foreign_key :hd_diary_slots, :users, column: :created_by_id add_foreign_key :hd_diary_slots, :users, column: :updated_by_id add_foreign_key :hd_diary_slots, :hd_diurnal_period_codes, column: :diurnal_period_code_id end end
Version data entries
171 entries across 171 versions & 1 rubygems