Skip to content

Backport `database_tasks:` from Rails 7.x

Kamil Trzciński requested to merge backport-database-tasks into master

What does this MR do and why?

Related to:

Supersedes the:

The problem is that if we have two databases configured that point to the same database: we will fail to load schema onto main:. This is due to fact that a rake task of db:schema:load processes databases in order, and we try to load effectively the same schema twice.

To overcome this the Rails 7 introduces database_tasks: false flag that allows to ignore some configurations from being migrated: https://github.com/rails/rails/commit/a77dd104ea9557d26d311d17a8b53c8ab7d7f8a8

This backports this feature as we will have to support it at some point and is better than to implement hacks for this behavior as proposed in supersedes MRs.

This is no-op unless database_tasks: false is set in config/database.yml. The database_tasks: false should be set if host+database effectively points to the same primary database. As here:

# main/ci points to the same database
production:
  main:
    host: postgres
    database: gitlabhq_main
  ci:
    host: postgres
    database: gitlabhq_main
    database_tasks: false

# main/ci points to different databases
production:
  main:
    host: postgres
    database: gitlabhq_main
  ci:
    host: postgres
    database: gitlabhq_ci
    # database_tasks: true: the default

This indicates that it would be best if database_tasks could be configured for all environments (Omnibus+CNG) to natively support Phase 4 without any special behavior.

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 Kamil Trzciński

Merge request reports