title: While running specs entries are getting delete from schema migrations table
body: <p>When upgraded to rails 6.1 my specs are failing due to entries are getting delete from schema_migrations table</p>
  <pre><code>ActiveRecord::SchemaMigration.count
     (2.1ms)  SELECT COUNT(*) FROM &quot;SCHEMA_MIGRATIONS&quot;
   =&gt; 1
  
  
  ActiveRecord::NoEnvironmentInSchemaError:
  
  Environment data not found in the schema. To resolve this issue, run:
  
          bin/rails db:environment:set RAILS_ENV=test
  
  Failure/Error: ActiveRecord::Migration.maintain_test_schema!
  
  ActiveRecord::PendingMigrationError:
  
  
    Migrations are pending. To resolve this issue, run:
  
            bin/rails db:migrate RAILS_ENV=test
  </code></pre>
  <p>When I run the following command</p>
  <pre><code>    bin/rails db:environment:set RAILS_ENV=test
  </code></pre>
  <p>It adds entry in the schema_migrations table.</p>
  <p>But when I run</p>
  <pre><code>rspec spec/ 
  </code></pre>
  <p>It deleted all my entries from the schema_migrations table except 1 entry. I suspect the issue is in database cleaner. Also, I check few <a href="https://stackoverflow.com/questions/38209186/rails-5-rspec-environment-data-not-found-in-the-schema">post</a> but so far no luck</p>
  <p>rails_helper.rb</p>
  <pre><code>require 'simplecov'
  SimpleCov.start 'rails'
  # This file is copied to spec/ when you run 'rails generate rspec:install'
  require 'spec_helper'
  ENV['RAILS_ENV'] ||= 'test'
  require File.expand_path('../../config/environment', __FILE__)
  # Prevent database truncation if the environment is production
  abort(&quot;The Rails environment is running in production mode!&quot;) if Rails.env.production?
  require 'rspec/rails'
  require 'json_matchers/rspec'
  # Add additional requires below this line. Rails is not loaded until this point!
  
  require 'database_cleaner'
  
  Shoulda::Matchers.configure do |config|
    config.integrate do |with|
      with.test_framework :rspec
      with.library :rails
    end
  end
  
  #
  Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
  
  ActiveRecord::Migration.maintain_test_schema!
  
  RSpec.configure do |config|
    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
    config.fixture_path = &quot;#{::Rails.root}/spec/fixtures&quot;
  
    config.use_transactional_fixtures = true
  
    config.infer_spec_type_from_file_location!
  
    # Filter lines from Rails gems in backtraces.
    config.filter_rails_from_backtrace!
    # arbitrary gems may also be filtered via:
    # config.filter_gems_from_backtrace(&quot;gem name&quot;)
    config.include FactoryBot::Syntax::Methods
  
    config.before(:suite) do
      DatabaseCleaner.clean_with :truncation, expect: %w(ar_internal_metadata schema_migrations)
      DatabaseCleaner.strategy = :transaction
    end
  
    config.around(:each) do |example|
      DatabaseCleaner.cleaning do
        example.run
      end
    end
  
    config.include RequestSpecHelper
    config.include ControllerSpecHelper
  end
  </code></pre>
  <p>database_cleaner (2.0.1)<br/>
  rails (6.1)<br/>
  ruby (2.5.0)<br/>
  activerecord-oracle_enhanced-adapter (6.1.4)<br/>
  ruby-oci8 (2.2.6.1)</p>
  <p>Note: I am using oracle as a database</p>