Skip to content

Properly enhance multi-db partitioning rake tasks

Patrick Bair requested to merge pb-properly-enhance-multidb-rake-tasks into master

What does this MR do and why?

Related to #352770 (closed)

With the addition of multiple databases, many of the rake tasks now have variants for each database, like:

rails db:migrate
rails db:migrate:main
rails db:migrate:ci

This MR fixes existing use of enhance to create dynamic partitions on all variants of these tasks.

How to set up and validate locally

  1. Setup multiple databases according https://docs.gitlab.com/ee/development/database/multiple_databases.html#development-setup
  2. Drop the existing database (or you can configure a new one if you need data in yours, as long as the schema is not loaded)
    rails db:drop && rails db:create
  3. Load the schema in the main database only:
    rails db:structure:load:main
    or with:
    rails db:schema:load:main
  4. Look for partitions on a partitioned table, like audit_events. On master the partitions will not exist, but on this branch they will:
    -- master
    \d audit_events
    ...
    Number of partitions: 0
    -- this branch
    \d audit_events
    ...
    Number of partitions: 8

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Patrick Bair

Merge request reports