Periodically save last activity date data from Redis to the database

This MR adds a cron worker that persists the last activity of users that were active the day before.

The cron is runs at 00:30 every day and loop per batch of 100 users (to avoid a too high query pressure).

The two first commits will be backported to CE.

What this MR does:

  • Backfill from latest last_activity_on or first current_sign_in_at
  • Post-deployment migration migrates last_activity_on from Redis, and fallback to current_sign_in_at and created_at
    • Tested on MySQL
    • For ~1 million users (1/3 with activity in Redis, 1/3 with a current_sign_in_at and 1/3 with a created_at, the migrations takes around ~3-4 minutes
  • Migration approved by a DB/migration specialist
  • Squash commits to be backported to CE into a few logical ones
  • Backport some commits to CE

Closes gitlab-ce#27790

Merge request reports