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

Migrations ignores shared section in database.yml #45299

Closed
jandudulski opened this issue Jun 8, 2022 · 2 comments · Fixed by #45309
Closed

Migrations ignores shared section in database.yml #45299

jandudulski opened this issue Jun 8, 2022 · 2 comments · Fixed by #45309
Assignees

Comments

@jandudulski
Copy link

jandudulski commented Jun 8, 2022

Steps to reproduce

  • create a new app
  • add multiple databases
  • separate migrations for each one with migrations_paths config value
  • create migrations & run them - everything should be fine at this point
  • extract migrations_paths from each stage to shared section
  • Rails.application.config_for(:database) loads yaml as expected with merged values
  • rails db:migrate and db:migrate:status ignores shared config

Example app with reproduce: https://github.com/jandudulski/shared_migrations_bug

Expected behavior

Use shared section for migrations.

Actual behavior

Shared section is ignored.

System configuration

Rails version: verified on 6.1 and 7.0

Ruby version: N/A

@jandudulski jandudulski changed the title MIgrations ignores shared section in database.yml Migrations ignores shared section in database.yml Jun 8, 2022
@eileencodes eileencodes self-assigned this Jun 8, 2022
@eileencodes
Copy link
Member

Hey @jandudulski thanks for the report! I've fixed this in #45309 and backported it to 7-0-stable in fe2a34d.

@jasonkarns
Copy link
Contributor

@jandudulski Are you able to confirm latest rails behaves as expected for you? I might be missing something, but when I run the demo app (https://github.com/jandudulski/shared_migrations_bug) against Rails 7.0.4.2, I end up with the shared options merged "below" each db config.

sample from ActiveRecord::Base.configurations:

   #<ActiveRecord::DatabaseConfigurations::HashConfig:0x0000000109d1f5d8
    @configuration_hash=
     {:foo=>{"migrations_paths"=>["db/foo"]},
      :bar=>{"migrations_paths"=>["db/bar"]},
      :adapter=>"sqlite3",
      :pool=>5,
      :timeout=>5000,
      :database=>"db/foo_dev.sqlite3"},
    @env_name="development",
    @name="foo">,

Note how the {foo:, bar:} migrations_paths hash from shared is added to the development foo database? I would not have expected to see any configuration for the bar database to be in the foo database's configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants