Create background migration for backfilling artifact expiry date
Summary
To support the change at https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/10177 we need to build a background migration that backfills artifact entries that don't have an expiry date set.
- For any existing artifact without an expiration date that was created > 15 months ago and before Jun 22, 2020 set the expiration date to 3 months from the next 22nd of the current or next month (whichever comes first).
- For any existing artifact without an expiration date that has a create date less than 15 months ago and created before June 22, 2020 set the expiration date to 1 year from the next 22nd of the current or next month (whichever comes first).
- Example 1 (Assuming release on Oct 22, 2020) - a job artifact with a creation date Jan 1, 2020 and no expiration date would get an expiration date of Jan 1, 2021.
- Example 2 (Assuming release on Oct 22, 2020) - a job artifact with a creation date of Jul 1, 2019 and no expiration date would get an expiration date of January 22, 2021.
By not changing files created after June 22, 2020 we slim down the amount of files impacted which makes this faster and address that when a user has clicked keep
the background mechanism is to set the expire_in value to null. This reduces the number of users we could impact by eventually archiving files without a date as brought up in this comment from @fabiopitino.
This is a pretty huge table (500 - 800M rows) and we need to batch this while taking into consideration not to write lock the table for too long.
Edited by James Heimbuck