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

Rails app with multiple databases: Primary schema file getting overwritten by secondary schema file #95

Open
sandeep-patle1508 opened this issue Sep 29, 2021 · 0 comments

Comments

@sandeep-patle1508
Copy link
Contributor

Hi,

We are trying to set up multiple databases with our Rails 6.1.3.2 application. Due to this gem we are facing an issue.

When we are running rails db:migrate

it is overwriting the primary db/schema.rb file with secondary schema file db/marketing_sync_board_schema.rb. After the migration command run both are the same.

They are not causing any database label changes.

Also if we are using database-specific command it is working fine.
rails db:migrate
rails db:migrate:marketing_sync_board

sample database.yml with multi database setup.

default: &default
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: multi_db_test_app_development
  username: admin
  password:
  pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>

marketing_sync_board_default: &marketing_sync_board_default
  <<: *default
  host: localhost
  username: admin
  password:
  database: marketing_sync_board_development
  migrations_paths: db/marketing_sync_board_migrate

development:
  primary:
    <<: *default
    database: multi_db_test_app_secondary_development
  marketing_sync_board:
    <<: *marketing_sync_board_default

Please let me know if you need more details here.

jenseng pushed a commit that referenced this issue Jan 2, 2024
)

Fix following issue(#95). This is the rebase from pull request #98.

**Background:**
We are trying to set up multiple databases with our **Rails 7**
application. Due to this gem, we are facing an issue.

When we are running **rails db:migrate**

it is overwriting the primary **db/schema.rb** file with secondary
schema file **db/marketing_sync_board_schema.rb**. After the migration
command run both are the same.

They are not causing any database label changes.

Also if we are using database-specific command it is working fine. 
`rails db:migrate`
`rails db:migrate:marketing_sync_board`

sample database.yml with multi database setup.
<pre>
default: &default
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: multi_db_test_app_development
  username: admin
  password:
  pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>

marketing_sync_board_default: &marketing_sync_board_default
  <<: *default
  host: localhost
  username: admin
  password:
  database: marketing_sync_board_development
  migrations_paths: db/marketing_sync_board_migrate

development:
  primary:
    <<: *default
    database: multi_db_test_app_secondary_development
  marketing_sync_board:
    <<: *marketing_sync_board_default
</pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant