Skip to content

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 to audit_events_202001
  • rename that same partition primary key from audit_events_part_202001_pkey to audit_events_202001_pkey

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Patrick Bair

Merge request reports

Loading