Sync catalog_resource_versions.released_at with releases.released_at
What does this MR do and why?
In !136139 (merged), we added a new column named released_at
to catalog_resource_versions
. This MR is the next step to denormalize the releases.released_at
data in the catalog_resource_versions
table.
This denormalization will eventually allow us to avoid or reduce the need to JOIN the catalog_resource_versions
and releases
tables in the Ci::Catalog::Resources::Version
model. (Note: In the next step, we will backfill the released_at
data before updating the queries.)
Since released_at
is a non-critical column and is unlikely to go out of sync with releases
, we determined that syncing the value via model callbacks would be a sufficient process (see issue for details.)
Resolves Step 2 of 4 in #430117 (closed).
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Create a catalog resource project. You can seed one quickly by running the following in your gitlab directory:
bundle exec rake "gitlab:seed:ci_catalog_resources[<GROUP-PATH>, 1, true]"
-
In the UI, create a new release for your catalog resource project. Take note of the release date.
-
Now in the Rails console, verify that the
released_at
column of the version has been synchronized.
project = Project.find(<YOUR-PROJECT-ID>)
project.catalog_resource.versions.last.read_attribute(:released_at)
- Back in the UI, update the release's release date. Then again run the command from the previous step and verify that the
released_at
column value has been updated to the correct date.
Related to #430117 (closed)