Skip to content

Commit

Permalink
Rails main fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zendesk-edytaroz committed Aug 6, 2024
1 parent 329c7eb commit 45c3691
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/migration_tools/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ def migrations_paths
end

def migrator(target_version = nil)
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR == 1
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
ActiveRecord::Base.connection.schema_migration
).migrations, target_version)
elsif ActiveRecord::VERSION::MAJOR >= 8 || (ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 2)
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
ActiveRecord::Base.connection_pool.schema_migration
).migrations, target_version)
else
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
Expand All @@ -42,11 +47,16 @@ def migrator(target_version = nil)
end

def migrate_up(migrations, target_version)
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
if (ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR == 1)
ActiveRecord::Migrator.new(:up, migrations,
ActiveRecord::Base.connection.schema_migration,
ActiveRecord::Base.connection.internal_metadata,
target_version)
elsif ActiveRecord::VERSION::MAJOR >= 8 || (ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 2)
ActiveRecord::Migrator.new(:up, migrations,
ActiveRecord::Base.connection_pool.schema_migration,
ActiveRecord::Base.connection_pool.internal_metadata,
target_version)
else
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
end
Expand Down

0 comments on commit 45c3691

Please sign in to comment.