Patch ActiveRecord::Generators::Migration#configured_migrated_path to exclude post-migrations path
What does this MR do and why?
We can set the migrations_paths
in the database configurations to tell Rails where the migrations for the additional database will live when using the --database
flag. We use this setting also to include the Geo post-deployment migrations path.
The problem is that the Rails migration generator joins the elements within the array into one path while creating the migration file, which breaks both regular and post-migration for the Geo database because the migration file will be written in the wrong place.
This patch modifies ActiveRecord::Generators::Migration#configured_migrated_path to exclude any post-migration path, and always return only one value while creating a migration file.
For more context:
- https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/patch/database_config.rb#L14-L16
- https://github.com/rails/rails/blob/v6.1.4.7/activerecord/lib/rails/generators/active_record/migration.rb#L42-L49
- https://github.com/rails/rails/blob/v6.1.4.7/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb#L17
Related issues
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.