Rename partitions when swapping partitioned tables
What does this MR do?
Related to #241267 (closed)
In !44655 (merged), a migration helper was added that implements the final step of a partitioning migration: swapping the original non-partitioned table with the partitioned copy. The swap is accomplished by transactionally renaming the two tables (as well as some other dependent objects).
This MR builds on that change by also renaming all the partitions associated with the partitioned table, so their names match the new naming schema of the parent table. As part of that renaming process, the primary key is also renamed, since by default the primary key name is "#{table_name}_pkey"
.
For example, if a partitioned table of audit_events_part
is renamed to simply audit_events
:
- rename a partition with name
audit_events_part_202001
toaudit_events_202001
- rename that same partition primary key from
audit_events_part_202001_pkey
toaudit_events_202001_pkey
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team