Geo: We need an OOP standardized solution to backfill standard/default attributes for old records

Summary

We have some situations where we are doing writing operations to the database in a GET request (which is supposed not to do write operations). This is a bad pattern as it colides with how Geo (#76 (closed)) secondary node expects our routes to work.

I can try to generalize it as:

  • We added a new column, but did not backfilled existing records using a migration
  • We changed column behavior, but did not migrated existing records using a migration
  • We added some cache in the database, but did not backfilled the cached column using a migration
  • We are caching data only on first access and saving it to the database

(See related issues below for more meaningful examples)

Related issues / Merge Requests

Possible fixes

We can create a helper to standardize how we handle the backfilling, so we have a single-point in the codebase where we can do some if Gitlab::Geo.secondary? check.

We should have something generic we can use in GitLab CE and change the helper code in EE to include the check, as CE doesn't know about Geo.

cc @DouweM @stanhu @rspeicher @smcgivern @dbalexandre