Load schema when running db:migrate on fresh dbs#53320
Merged
jeremy merged 3 commits intorails:mainfrom Oct 28, 2024
Merged
Conversation
2eab749 to
e12a3b9
Compare
excid3
reviewed
Oct 16, 2024
Contributor
|
Ran into this today and this seemed to fix it for me. 👍 |
e12a3b9 to
77eed10
Compare
zzak
reviewed
Oct 18, 2024
Loading database schemas before db:migrate for a single database was fixed in rails#52830. However, this approach fails when multiple databases are defined. This fix addresses the issue by moving schema loading to occur before initiating database migrations. Fixes rails#52829
77eed10 to
658c86a
Compare
jeremy
added a commit
that referenced
this pull request
Oct 28, 2024
Backport #53320 to 8-0-stable. Loading database schemas before db:migrate for a single database was fixed in #52830. However, this approach fails when multiple databases are defined. This fix addresses the issue by moving schema loading to occur before initiating database migrations. Fixes #52829 Co-authored-by: Marek Kasztelnik <[email protected]>
mnordin
added a commit
to mnordin/webhook-deliverer
that referenced
this pull request
Nov 4, 2024
I discovered that rake db:drop will cause issues when re-creating the databases on a multi database config, causing the queue schema not to load its migrations and we end up with an empty database. This is not affected by SolidQueues migrations being faulty, it seems to be related to the multi database setups only running the migrations for the primary database. I discovered this while playing around with SolidCable and decided to backtrack and fix this issue in main branch. This is due to a bug in Rails: rails/rails#52829 It was fixed by rails/rails#53320 but is part of Rails main and not 8.0.0.rc2. Revert this commit when a new release candidate is released including the rails/rails@ecbdfbc commit.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / Background
Loading database schemas before
db:migratefor a single database was fixed in #52830. However, this approach fails when multiple databases are defined. This fix addresses the issue by moving schema loading to occur before initiating database migrations.Detail
db:migratehas different logic when single or multiple databases are defined (https://github.com/rails/rails/blob/main/activerecord/lib/active_record/railties/databases.rake#L92-L102). When multiple DBs are defined,migrationmethod is invoked only for the DBs with pending migrations. The fix moves DBs schema load for new DBs before DBs migrations are invoked.Additional information
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]