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

fix: allow db:schema:load to work for rails 6.0 and 6.1 #343

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

vprigent
Copy link
Collaborator

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.

@@ -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)
Copy link
Collaborator Author

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.

@vprigent
Copy link
Collaborator Author

@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.)

@vprigent vprigent marked this pull request as ready for review September 27, 2024 10:47
Copy link
Contributor

@jgmontoya jgmontoya left a 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)

@@ -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)
Copy link
Contributor

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

@vprigent vprigent merged commit b10fe88 into ilyakatz:9-1-stable Sep 28, 2024
10 checks passed
@vprigent vprigent deleted the fix-rails-6.x-compat branch September 28, 2024 07:55
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

Successfully merging this pull request may close these issues.

2 participants