Migrations

updated process for migrations Jan 2018

CCB Approved Services

  1. Create Org
  2. Attach Service Approval
  3. Resolve Informals
  4. Run attendance import
  5. Run booking auto create
  6. Run balance reset
  7. Import Transfer amounts
  8. Import parent emails

Start Ruby console

ssh into prod.

cd /home/bitnami/ccsm_prod
RACK_ENV=production bundle exec padrino console

Set all balances to zero (no service allocation)

# in ruby console

Organisation[9999999].parents.each {|v| Payment.create(amount: v.balance, parent_id: v.id, payment_date: Date.parse('2020-01-01'), notes: "Migration balance adjustment", src: 'other', src_ref: 'migration_2_sc') }

# 9999999 is the organisation id
# payment_date can be today (Date.today)
# notes and src_ref can be changed (but give it something unique, can be easily deleted if by mistake)
# to get balance at, call balance with a single param v.balance(Date.parse('2018-01-01'))

Set all balances to zero (multi-service allocation)

cd ccms

RACK_ENV=staging bundle exec padrino run script/reset_parent_service_balance.rb [org_id] [adjustment date 2018-02-01]

RACK_ENV=production bundle exec padrino run script/reset_parent_service_balance.rb [org_id] [adjustment date 2018-02-01]

auto generate bookings and session codes

you now must specify which week to use as the baseline

cd /home/bitnami/ccms_prod

RACK_ENV=production bundle exec rake auto_bookings[service_id,we_date]

e.g. rake auto_bookings[100,2018-04-29]

auto generate bookings and split rooms

the cmd to generate booking and split room based on dob

$cd ccms_prod
$RACK_ENV=production bundle exec rake auto_booking[445,2018-05-20,2016-01-01_2014-01-01]

so that is service id, week ending to sample booking and dobs joined by '_'

alternatively just rerun the entire import job in console

$cd ccms_prod
$RACK_ENV=production REDIS_URL=redis://localhost:6379/0 REDIS_PROVIDER=redis://localhost:6379/0 bundle exec padrino console

then in console
[1] pry(main)> NewClientImportWorker.perform_async(445,'2018-05-20','2017-01-01_2014-01-01')
this just kicks the process off and exits . an email will be sent to support on completion

Pull Attendance history

Usage:

under ccms_prod dir:

FULL HISTORY
============

RACK_ENV=production bundle exec padrino run script/ccms_load_atts.rb <SC service id>

Query recent atts.
=================

RACK_ENV=production bundle exec padrino run script/ccms_load_atts.rb <SC service id> recent

the script will auto exit when all operations finished, there is no need to monitor the progress.

p.s. upon exit the script will throw  Concurrent::RejectedExecutionError, which is normal.

old method

ssh into prod.

cd /home/bitnami/ccsm_prod
RACK_ENV=production bundle exec padrino console

wait...

after console loaded, type:

require './sucker_punch_jobs/dss_att_job.rb' [enter]

DssAttJob.perform_async(302, nil, true) [enter]

wait for a while (seconds) and refresh att list page to see if statuses updated.
* 302 is the SC service id.

* third param true is recent two weeks. false is three years.

Pull Payments

in ccms_prod folder, run script with service_id

~/ccms_prod$ RACK_ENV=production bundle exec padrino run script/ccs_payment_query.rb 482

Requery all atts on a CCMS enrolment.

bitnami@sfng:~$ cd ccms_prod bitnami@sfng:~/ccms_prod$ RACK_ENV=production bundle exec padrino run script/ccms_atts_by_enrol.rb service_id dss_enrolment_id

e.g. RACK_ENV=production bundle exec padrino run script/ccms_atts_by_enrol.rb 10 4-SDFSDF