<commit_before># frozen_string_literal: true

require "cases/helper"

class PostgresqlExtensionMigrationTest < ActiveRecord::PostgreSQLTestCase
  self.use_transactional_tests = false

  class EnableHstore < ActiveRecord::Migration::Current
    def change
      enable_extension "hstore"
    end
  end

  class DisableHstore < ActiveRecord::Migration::Current
    def change
      disable_extension "hstore"
    end
  end

  def setup
    super

    @connection = ActiveRecord::Base.connection

    @old_table_name_prefix = ActiveRecord::Base.table_name_prefix
    @old_table_name_suffix = ActiveRecord::Base.table_name_suffix

    ActiveRecord::Base.table_name_prefix = "p_"
    ActiveRecord::Base.table_name_suffix = "_s"
    ActiveRecord::SchemaMigration.reset_table_name
    ActiveRecord::InternalMetadata.reset_table_name

    ActiveRecord::SchemaMigration.delete_all rescue nil
    ActiveRecord::Migration.verbose = false
  end

  def teardown
    ActiveRecord::SchemaMigration.delete_all rescue nil
    ActiveRecord::Migration.verbose = true

    ActiveRecord::Base.table_name_prefix = @old_table_name_prefix
    ActiveRecord::Base.table_name_suffix = @old_table_name_suffix
    ActiveRecord::SchemaMigration.reset_table_name
    ActiveRecord::InternalMetadata.reset_table_name

    super
  end

  def test_enable_extension_migration_ignores_prefix_and_suffix
    @connection.disable_extension("hstore")

    migrations = [EnableHstore.new(nil, 1)]
    ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::Base.connection.schema_migration).migrate
    assert @connection.extension_enabled?("hstore"), "extension hstore should be enabled"
  end
<commit_msg>Ensure to reset actually used `@connection.schema_migration`'s table name<commit_after># frozen_string_literal: true

require "cases/helper"

class PostgresqlExtensionMigrationTest < ActiveRecord::PostgreSQLTestCase
  self.use_transactional_tests = false

  class EnableHstore < ActiveRecord::Migration::Current
    def change
      enable_extension "hstore"
    end
  end

  class DisableHstore < ActiveRecord::Migration::Current
    def change
      disable_extension "hstore"
    end
  end

  def setup
    super

    @connection = ActiveRecord::Base.connection

    @old_table_name_prefix = ActiveRecord::Base.table_name_prefix
    @old_table_name_suffix = ActiveRecord::Base.table_name_suffix

    ActiveRecord::Base.table_name_prefix = "p_"
    ActiveRecord::Base.table_name_suffix = "_s"
    @connection.schema_migration.reset_table_name
    ActiveRecord::InternalMetadata.reset_table_name

    @connection.schema_migration.delete_all rescue nil
    ActiveRecord::Migration.verbose = false
  end

  def teardown
    @connection.schema_migration.delete_all rescue nil
    ActiveRecord::Migration.verbose = true

    ActiveRecord::Base.table_name_prefix = @old_table_name_prefix
    ActiveRecord::Base.table_name_suffix = @old_table_name_suffix
    @connection.schema_migration.reset_table_name
    ActiveRecord::InternalMetadata.reset_table_name

    super
  end

  def test_enable_extension_migration_ignores_prefix_and_suffix
    @connection.disable_extension("hstore")

    migrations = [EnableHstore.new(nil, 1)]
    ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::Base.connection.schema_migration).migrate
    assert @connection.extension_enabled?("hstore"), "extension hstore should be enabled"
  end

{'fraction_non_alphanumeric': 0.07581120943952803, 'fraction_numerical': 0.0005899705014749262, 'mean_word_length': 5.19926873857404, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3437651', 'n_tokens_mistral': 1001, 'n_tokens_neox': 983, 'n_words': 169}