Cater for a new (non-breaking) index format where there are two arrays instead of one - the second array allows passing of standard Mongo index options (e.g. sparse=>true, unique=>true)
Add new tests to check
Tested the dependency manually inside local TARL to prove the index gets generated correctly and no other fallout.
We drove this off the existing tests and copious amounts of temporary logging. Adding more tests that support that new two array format (where second array is standard Mongo index options)
Once all passing in tests, copied this code into TARL's vendor directory and updated the tenant-pods.json file in TARL to add a new index onto CBD_users personaUsers.guid that also had sparse=>true & unique=>true.
Reloaded TARL data, no indexes present (this also generates the tripod config)
Kicked off Setup Console "ensureIndexes"
Looked in TARL and Tripod logs for errors (non present) and also checked CBD_users indexes - new index was present with the correct index options.
As a safety test we also tried the index without the sparse=>true and the index generation failed as there are many documents in local TARL that have no persona guid set.
Issues
It's worth noting a few issues encountered along the way with this...
TARL's docker-compose.yml has a :delegated suffix on the vendor volume mount, effectively caching changes so when you copy new code in it wasn't being picked up. We temporarily removed this to prove our changes, but sometimes it still didn't pick up changes quickly enough. The only reliable option was to stop/start the RL containers and then code in vendor was correctly reflected.
It would have been nice to have left a logger statement in at the point of creating the index, just so we can see the options, but the logger isn't available in the IndexUtils class.
Example
From a db.CBD_users.getIndexes() in the local Mongo life database, the new index is present:
Fix
personaUsers.guid
: https://github.com/techfromsage/rl-app/pull/4461Approach taken
tenant-pods.json
file in TARL to add a new index onto CBD_userspersonaUsers.guid
that also had sparse=>true & unique=>true.sparse=>true
and the index generation failed as there are many documents in local TARL that have no persona guid set.Issues
It's worth noting a few issues encountered along the way with this...
docker-compose.yml
has a:delegated
suffix on thevendor
volume mount, effectively caching changes so when you copy new code in it wasn't being picked up. We temporarily removed this to prove our changes, but sometimes it still didn't pick up changes quickly enough. The only reliable option was to stop/start the RL containers and then code invendor
was correctly reflected.Example
From a
db.CBD_users.getIndexes()
in the local Mongolife
database, the new index is present: