audius-protocol
audius-protocol copied to clipboard
Backfill artist pick
Description
Backfill artist pick track ids in the users
table in the discovery DB with the pinnedTrackIds
in SocialHandles
in the identity DB.
Update records in-place for simplicity. This does mean that user records in elasticsearch won't be updated but we'll need to reindex all user records in elasticsearch anyway to add the new artist_pick_track_id
field.
This PR can only be merged after dual writes for artist pick are turned on in the client, which is behind the user_entity_manager
switch and depends on the entity manager rollout that should happen next week.
Once the client is writing to both identity and discovery DBs, I'll pull a final csv of handles <-> pinned track ids from identity and check it in here to be used in this migration (the csv committed right now is data from 10/25). Dual writes will catch any updates to artist picks after I generate the csv, so we don't have to worry about that data being missing from discovery.
If we need to downgrade this migration, we can just set all artist pick ids back to null in discovery. The source of truth is still identity and dual writes ensure consistency between the two systems going forward in time from the backfill.
Tests
Ran backfill (up and down) locally. Verified changes via psql. Repeat with staging data with staging discovery db clone.