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

Adding database_tasks: false to primary database breaks migrations in another database #51757

Open
paul-at opened this issue May 7, 2024 · 1 comment

Comments

@paul-at
Copy link

paul-at commented May 7, 2024

Steps to reproduce

Create a Rails app and define two databases.

development:
  primary:
    <<: *default
    database: storage/development.sqlite3
  secondary:
    <<: *default
    database: storage/development2.sqlite3
    migrations_paths: db/secondary_migrate

Run rails db:create, add database_tasks: false to the primary database:

  primary:
    <<: *default
    database: storage/development.sqlite3
    database_tasks: false

Create a test migration:

mkdir db/secondary_migrate
bin/rails generate migration CreateDogs name:string --database secondary

Run rails db:migrate

Expected behavior

Migration should execute in secondary database

Actual behavior

Nothing happens.

Furthermore, there appears to be discrepancy between how db:migrate lists pending migrations and how it's checked in db:migrate:status and db:setup as, unlike db:migrate they can see the pending migration:

$ rails db:migrate:status

database: storage/development2.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
  down    20240507134124  Create dogs

$ rails db:setup
Database 'storage/development2.sqlite3' already exists
Database 'storage/test.sqlite3' already exists
Database 'storage/test2.sqlite3' already exists
You have 1 pending migration:
  20240507134124 CreateDogs
Run `bin/rails db:migrate` to update your database then try again.

The secondary database migration executes correctly if database_tasks: false is removed from primary.

System configuration

Rails version: edge and 7.1.3.2 have the same behaviour
Ruby version: 3.3.0

@paul-at
Copy link
Author

paul-at commented May 7, 2024

I suspect this may be related to #45552

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