Skip to content

Commit

Permalink
fixup! Support latest beta version rails
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSokov committed Jun 6, 2024
1 parent bae7b81 commit f633a35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
/spec/reports/
/tmp/
/test/dummy_app/tmp/
/test/dummy_app/db/migrate/*.rb
/test/dummy_app/db/schema.rb
/test/dummy_app/db/*/*.rb
/test/dummy_app/db/*.rb
.ruby-version
.ruby-gemset
/gemfiles/*.gemfile.lock
19 changes: 14 additions & 5 deletions test/support/test_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,26 @@ def migrated_files(db_config = nil)

def cleanup_call(prefix_name = nil)
delete_migrations_files(prefix_name)
if ActiveRecord::SchemaMigration.respond_to?(:create_table)
ActiveRecord::SchemaMigration.create_table
else
ActiveRecord::SchemaMigration.new(ActiveRecord::Base.connection).create_table
end
create_schema_migration_table
run_sql("delete from schema_migrations")
remove_app_dir(MIGRATED_PATHS.fetch(prefix_name&.to_sym, migrated_paths.first))
define_migrations(prefix_name)
Rails.application.load_tasks
end

def create_schema_migration_table
if ActiveRecord::SchemaMigration.respond_to?(:create_table)
ActiveRecord::SchemaMigration.create_table
else
ar_version = Gem::Version.new(ActiveRecord::VERSION::STRING)
if ar_version >= Gem::Version.new("7.2.0") || (ar_version >= Gem::Version.new("7.1.0") && ar_version.prerelease?)
ActiveRecord::SchemaMigration.new(ActiveRecord::Base.connection_pool).create_table
else
ActiveRecord::SchemaMigration.new(ActiveRecord::Base.connection).create_table
end
end
end

def delete_migrations_files_for(path)
Dir.glob(app_file("#{path}/**/*.rb")).each do |file|
remove_app_dir(file)
Expand Down

0 comments on commit f633a35

Please sign in to comment.