Sha256: 92140cb4373e8110b90f20ecf9be1bae95c65d6337318271253932e588e58330
Contents?: true
Size: 1.27 KB
Versions: 173
Compression:
Stored size: 1.27 KB
Contents
class CreateAdmissionsRequests < ActiveRecord::Migration[5.1] def change create_table :admission_request_reasons do |t| t.string :description, null: false t.datetime :deleted_at, index: true t.timestamps null: false end create_table :admission_requests do |t| t.references :patient, null: false, foreign_key: true t.integer :reason_id, null: false, index: true t.references :hospital_unit, foreign_key: true, index: true t.text :notes t.string :priority, null: false t.integer :position, null: false, default: 0, index: true t.datetime :deleted_at, index: true t.integer :updated_by_id, null: false, index: true t.integer :created_by_id, null: false, index: true t.timestamps null: false end # We only allow on patient with a current (deleted_at = NULL) row. # Indexing on [:patient_id, :deleted_at] does the trick because deleted_at is not used # in the if its NULL. add_index :admission_requests, [:patient_id, :deleted_at], unique: true add_foreign_key :admission_requests, :users, column: :created_by_id add_foreign_key :admission_requests, :users, column: :updated_by_id add_foreign_key :admission_requests, :admission_request_reasons, column: :reason_id end end
Version data entries
173 entries across 173 versions & 1 rubygems