-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added code to 61 gemfile to fix issues with concurrent_ruby version a…
…nd added logic to MigrationHelper to deal with versions above and below Rails 7.0
- Loading branch information
Andy Reilly
committed
Jan 22, 2025
1 parent
d5961e7
commit 9a967ec
Showing
2 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
class MigrationHelper | ||
class << self | ||
def migrate(path) | ||
ActiveRecord::MigrationContext.new(path).migrate | ||
if Rails.version >= '7.0' | ||
ActiveRecord::MigrationContext.new(path).migrate | ||
elsif Rails.version < '7.0' | ||
ActiveRecord::MigrationContext.new(path, schema_migration).migrate | ||
end | ||
end | ||
|
||
def rollback(path) | ||
ActiveRecord::MigrationContext.new(path).rollback | ||
if Rails.version >= '7.0' | ||
ActiveRecord::MigrationContext.new(path).rollback | ||
elsif Rails.version < '7.0' | ||
ActiveRecord::MigrationContext.new(path, schema_migration).rollback | ||
end | ||
end | ||
|
||
# private | ||
# Commenting out as this is not needed. Was causing error due to deprecation of .connection superseded by | ||
# .with_connection. Removed schema_migration from new(path, schema_migrations) since it is optional | ||
# and all test now passing with rails 7.2. | ||
# def schema_migration | ||
# ActiveRecord::Base.connection.schema_migration | ||
# end | ||
private | ||
def schema_migration | ||
ActiveRecord::Base.connection.schema_migration | ||
end | ||
end | ||
end |