Release 2610
Trello card
Context
We want new schools to have preset availability info text and accept in-school bookings by default. We also want existing schools that have not specified availability info text/experience type to be backfilled with the defaults.
Changes proposed in this pull request
- Default school availability and backfill existing data
Add migration to default the availability_info text and set experience_type to in-school.
Backfill existing data to set defaults when the availability_info has not yet been specified by the user. Supports rolling back the availability_info, however we will not be able to determine the previous experience_type in all cases so this will remain as in-school. Using update_all without batching should be fine as it'll result in a single SQL query to do the update.
The schema has been updated to add a default precision to datetime attributes (the default is nil and will use the database default, so no change); this appears to be Rails 7 behaviour and must have been missed during the upgrade.
Guidance to review
I initially tried defaulting this in the model so that I could test it but it wasn't playing nice with the activerecord-import gem we use to mass import school data. I thought about breaking the backfill out into a rake task but it looks like we usually just let it run as part of the migrations, so opted to keep it consistent.
Testing this is a bit tricky; on staging you can SSH into the box and start a Rails console to verify the data looks correct:
cf ssh review-school-experience-2610
cd /app
export PATH=${PATH}:/usr/local/bin
bundle exec rails c
Bookings::School.where(availability_info: nil).count # 0
Bookings::School.where(experience_type: nil).count # 0
Bookings::School.where("availability_info LIKE '%not yet provided their availability%'").count #48014
Bookings::School.where("availability_info NOT LIKE '%not yet provided their availability%'").count # 291
The upshot of this change is that any schools that had onboarded but not yet set a flexible date description will now appear in search results; there are 67 such schools and the Trello ticket has been updated with anonymised information for these schools.