```ruby
ENV['RAILS_ENV'] ||= 'test'
require "test_app/config/environment"
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
require 'database_cleaner'

# Checks for pending migration and applies them before tests are run.
# ActiveRecord::Migration.maintain_test_schema!

RSpec.configure do |config|
  config.fixture_path = "#{::Rails.root}/spec/fixtures"

  config.use_transactional_fixtures = true

  config.infer_spec_type_from_file_location!
  config.filter_rails_from_backtrace!
end
```

Introduce a hacky way to run migrations from code across rails versions
user
```ruby
ENV['RAILS_ENV'] ||= 'test'
require "test_app/config/environment"
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
require 'database_cleaner'

# Checks for pending migration and applies them before tests are run.
# ActiveRecord::Migration.maintain_test_schema!
system("cd spec/test_app; bin/rake db:create db:migrate db:test:prepare")

RSpec.configure do |config|
  config.fixture_path = "#{::Rails.root}/spec/fixtures"

  config.use_transactional_fixtures = true

  config.infer_spec_type_from_file_location!
  config.filter_rails_from_backtrace!
end
```
assistant