Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATABASE option for railties:install:migrations #48579

Merged

Conversation

SixiS
Copy link
Contributor

@SixiS SixiS commented Jun 26, 2023

Motivation / Background

This Pull Request has been created because it is helpful to be able to specify which database you want
to install migrations to when using an engine with a Rails project that has multiple databases.

Detail

This Pull Request adds a DATABASE option to the railties:install:migrations rake task.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@SixiS SixiS force-pushed the database_option_for_railties_migrations_install branch 4 times, most recently from f5603ef to 331bafb Compare June 26, 2023 17:14
Comment on lines 631 to 638
destination = ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first
if ENV["DATABASE"].present? && ENV["DATABASE"] != "primary"
config = ActiveRecord::Base.configurations.configs_for(name: ENV["DATABASE"])
raise "Invalid DATABASE provided" if config.blank?
destination = config.migrations_paths
raise "#{ENV["DATABASE"]} does not have a custom migration path" if destination.blank?
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
destination = ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first
if ENV["DATABASE"].present? && ENV["DATABASE"] != "primary"
config = ActiveRecord::Base.configurations.configs_for(name: ENV["DATABASE"])
raise "Invalid DATABASE provided" if config.blank?
destination = config.migrations_paths
raise "#{ENV["DATABASE"]} does not have a custom migration path" if destination.blank?
end
if ENV["DATABASE"].present? && ENV["DATABASE"] != "primary"
config = ActiveRecord::Base.configurations.configs_for(name: ENV["DATABASE"])
raise "Invalid DATABASE provided" if config.blank?
destination = config.migrations_paths
raise "#{ENV["DATABASE"]} does not have a custom migration path" if destination.blank?
else
destination = ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first
end

…atabase they would like the migrations to be copied to.
@SixiS SixiS force-pushed the database_option_for_railties_migrations_install branch from 331bafb to 00ebbbd Compare June 26, 2023 17:28
@rafaelfranca rafaelfranca merged commit 37a56aa into rails:main Jun 26, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants