Add column workspaces_agent_config_version and backfill
Issue - Backend Migration: New field for workspaces_age... (#479461 - closed)
What does this MR do and why?
We need a new integer column workspaces_agent_config_version
on the workspace table to record which version of agent_config it belongs to.
and the second post_migration for backfill all existing workspaces.
MR acceptance checklist
-
have migration MR to introduce the new column -
have the post migration script to update on all values
Screenshots or screen recordings
The new column is up and also correct values are backfilled in the column.
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
For DB Review
If the migration itself is not reversible, details of how data changes could be reverted in the event of an incident.
We are introducing a new column, and also backfill data in post-migration. If the backfill script failed, we could revert the adding column migration, and re-do backfill safely.
Concise descriptions of possible user experience impact of an error.
If the adding column migration failed, the deployment will be blocked.
If the backfill column migration failed, there is no direct impact, as my application code would handle the column containing nil
value, and would work as expected.
Relevant data from the query plans that indicate the query works as expected; such as the approximate number of records that are modified or deleted.
There is a total number of xxx workspaces, and xxx workspaces_agent_config. See internal note below for actual numbers. The data set should be considered as tiny.
Query Plan
For first SQL in backfill script, and we could see only under 100 rows will be returned. And then we do bulk update one by one.
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/31453/commands/97638