3 ms·
With complex migrations, like spanning multiple tables or depending on external APIs, I sometimes use a variant of this. Where instead of migrating the underlyi
by janpot 5y ago
With complex migrations, like spanning multiple tables or depending on external APIs, I sometimes use a variant of this. Where instead of migrating the underlying database in "Migration 2", my version 3 would migrate on read:
- Read from new representation
- If not found:
- read X from old representation
- migrate X to new representation (complex business logic here)
- write migrated datum to new representation
- return migrated datum
- Either wait long enough until all data has been read at least once or systematically call your API for all records you want migrate (depending on the logic, you might want to throttle this)