-
Notifications
You must be signed in to change notification settings - Fork 194
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
fix: allow db:schema:load to work for rails 6.0 and 6.1 #343
Conversation
lib/data_migrate/database_tasks.rb
Outdated
@@ -68,28 +68,23 @@ def run_migration(migration, direction) | |||
end | |||
end | |||
|
|||
def schema_dump_path(db_config, format = ActiveRecord.schema_format) | |||
return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] | |||
unless Gem::Dependency.new("railties", "< 7.0").match?("railties", Gem.loaded_specs["railties"].version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've re-extracted this check to make it more intent that we only add these two methods for newer Rails versions that have more complex support for multiple databases. All the previous gem versions compatible with rails 6.0 specifically worked without these methods.
@jgmontoya would love your input on this once more. I might spend a bit more time tomorrow to validate my assumptions here with more complex rails apps. (I've just tested against the ruby and sql structure config on rails 6.0 and 6.1 but not with read-replica for example.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good idea, tbh I wouldn't invest too much more time/effort in extending support for rails 6.0 given it has been EOL for over a year (even 6.1 is becoming EOL next week afaik)
lib/data_migrate/database_tasks.rb
Outdated
@@ -68,28 +68,23 @@ def run_migration(migration, direction) | |||
end | |||
end | |||
|
|||
def schema_dump_path(db_config, format = ActiveRecord.schema_format) | |||
return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] | |||
unless Gem::Dependency.new("railties", "< 7.0").match?("railties", Gem.loaded_specs["railties"].version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change the unless
to an if
and flip the condition, I think it makes it easier to read
f94afe6
to
c2d2992
Compare
c2d2992
to
bdc3359
Compare
Still planning to only release this for 9-1. I suspect a better fix for 6.1 that would also support multi-databases might be a bit more tricky.
For a bit of context:
schema_dump_path is introduced in rails 7 and our task relies on that to improve the support for multiple databases, however full multiple data support was only handled in subsequent gem versions, so I'm hoping this patch will solve rails 6.x issues for people still using older rails versions.