lib/migration_tools/tasks.rb in migration_tools-1.8.0 vs lib/migration_tools/tasks.rb in migration_tools-1.9.0

- old
+ new

@@ -26,24 +26,35 @@ def migrations_paths ActiveRecord::Migrator.migrations_paths end def migrator(target_version = nil) - if ActiveRecord::VERSION::MAJOR >= 6 + 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 >= 6 + migrate_up(ActiveRecord::MigrationContext.new( + migrations_paths, ActiveRecord::SchemaMigration ).migrations, target_version) elsif ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 2 migrate_up(ActiveRecord::MigrationContext.new(migrations_paths).migrations, target_version) else migrate_up(ActiveRecord::Migrator.migrations(migrations_paths), target_version) end end def migrate_up(migrations, target_version) - if ActiveRecord::VERSION::MAJOR >= 6 + 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 >= 6 ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version) else ActiveRecord::Migrator.new(:up, migrations, target_version) end end @@ -86,11 +97,17 @@ else pending_migrations.each do |migration| migrator(migration.version).run end - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql + schema_format = if ActiveRecord::VERSION::MAJOR >= 7 + ActiveRecord.schema_format + else + ActiveRecord::Base.schema_format + end + + Rake::Task["db:schema:dump"].invoke if schema_format == :ruby + Rake::Task["db:structure:dump"].invoke if schema_format == :sql end end end end end