Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl populate past status changed by (1.8.0) #593

Merged
merged 8 commits into from Aug 3, 2016
15 changes: 15 additions & 0 deletions db/migrate/20160727152900_populate_past_status_changed_by_id.rb
@@ -0,0 +1,15 @@
class PopulatePastStatusChangedById < ActiveRecord::Migration
def change
ActiveRecord::Base.transaction do
statuses = PastStatus.where('created_at > ?', '2013-09-08')
statuses.each do |status|
audit = AuditRecovery.where(auditable_id: status.id).where(auditable_type: 'PastStatus').first
unless audit.nil?
changed_by_id = Identity.where(id: audit[:user_id]).pluck(:id).first
status.update_attributes(changed_by_id: changed_by_id)
puts "Updating status' changed_by_id column to identity id of #{changed_by_id}"
end
end
end
end
end
30 changes: 11 additions & 19 deletions db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160720151213) do
ActiveRecord::Schema.define(version: 20160727152900) do

create_table "admin_rates", force: :cascade do |t|
t.integer "line_item_id", limit: 4
Expand Down Expand Up @@ -103,8 +103,8 @@
t.integer "subject_count", limit: 4, default: 1
t.integer "protocol_id", limit: 4
t.boolean "new_with_draft", default: false
t.integer "minimum_visit_count", limit: 4, default: 0
t.integer "minimum_subject_count", limit: 4, default: 0
t.integer "minimum_visit_count", limit: 4
t.integer "minimum_subject_count", limit: 4
end

add_index "arms", ["protocol_id"], name: "index_arms_on_protocol_id", using: :btree
Expand Down Expand Up @@ -184,12 +184,6 @@
add_index "charges", ["service_id"], name: "index_charges_on_service_id", using: :btree
add_index "charges", ["service_request_id"], name: "index_charges_on_service_request_id", using: :btree

create_table "click_counters", force: :cascade do |t|
t.integer "click_count", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "clinical_providers", force: :cascade do |t|
t.integer "identity_id", limit: 4
t.integer "organization_id", limit: 4
Expand Down Expand Up @@ -528,10 +522,10 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
t.integer "changed_by", limit: 4
t.integer "changed_by_id", limit: 4
end

add_index "past_statuses", ["changed_by"], name: "index_past_statuses_on_changed_by", using: :btree
add_index "past_statuses", ["changed_by_id"], name: "index_past_statuses_on_changed_by_id", using: :btree
add_index "past_statuses", ["sub_service_request_id"], name: "index_past_statuses_on_sub_service_request_id", using: :btree

create_table "past_subsidies", force: :cascade do |t|
Expand Down Expand Up @@ -1016,20 +1010,18 @@
t.string "status", limit: 255, default: "Pending"
t.integer "approved_by", limit: 4
t.datetime "approved_at"
t.float "percent_subsidy", limit: 24
t.float "percent_subsidy", limit: 24, default: 0.0
end

add_index "subsidies", ["sub_service_request_id"], name: "index_subsidies_on_sub_service_request_id", using: :btree

create_table "subsidy_maps", force: :cascade do |t|
t.integer "organization_id", limit: 4
t.decimal "max_dollar_cap", precision: 12, scale: 4, default: 0.0
t.decimal "max_percentage", precision: 5, scale: 2, default: 0.0
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "organization_id", limit: 4
t.decimal "max_dollar_cap", precision: 12, scale: 4, default: 0.0
t.decimal "max_percentage", precision: 5, scale: 2, default: 0.0
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
t.float "default_percentage", limit: 24, default: 0.0
t.text "instructions", limit: 65535
end

add_index "subsidy_maps", ["organization_id"], name: "index_subsidy_maps_on_organization_id", using: :btree
Expand Down