Sha256: f339d30fc0ee8f0e4c64428d361ba4bc141f27b16165f21ad7a6d2c0e3101294
Contents?: true
Size: 1.22 KB
Versions: 16
Compression:
Stored size: 1.22 KB
Contents
class RenameAccessPlansToAccessPlanTypes < ActiveRecord::Migration[5.0] def change remove_column :access_profiles, :plan_id remove_column :access_profiles, :planned_on rename_table :access_plans, :access_plan_types create_table :access_plans do |t| t.integer :plan_type_id, null: false, index: true t.text :notes t.integer :patient_id, null: false, index: true t.integer :decided_by_id, index: true t.integer :updated_by_id, null: false, index: true t.integer :created_by_id, null: false, index: true t.datetime :terminated_at, index: true t.timestamps null: false end add_foreign_key :access_plans, :access_plan_types, column: :plan_type_id add_foreign_key :access_plans, :patients, column: :patient_id add_foreign_key :access_plans, :users, column: :decided_by_id add_foreign_key :access_plans, :users, column: :created_by_id add_foreign_key :access_plans, :users, column: :updated_by_id # There can only ever be one un-terminated plan per user - is the current one ActiveRecord::Base.connection.execute( "CREATE UNIQUE INDEX access_plan_uniqueness ON access_plans (patient_id, COALESCE(terminated_at, '1970-01-01'));" ) end end
Version data entries
16 entries across 16 versions & 1 rubygems