<commit_before>####### Important information ####################
# This file is used to setup a shared extensions #
# within a dedicated schema. This gives us the   #
# advantage of only needing to enable extensions #
# in one place.                                  #
#                                                #
# This task should be run AFTER db:create but    #
# BEFORE db:migrate.                             #
##################################################

namespace :db do
  desc 'Also create shared extensions schemas'
  task extensions: :environment do
    Ekylibre::Schema.setup_extensions
  end

  if Rails.env.development?
    task reinit: :environment do
      Lexicon.disable!

      schema_whitelist = ['information_schema', 'postgis', Lexicon::DISABLED_SCHEMA].freeze
      schemas = Ekylibre::Record::Base.connection
                  .execute("SELECT schema_name FROM information_schema.schemata")
                  .to_a
                  .map { |h| h['schema_name'] }
                  .reject {|schema| schema_whitelist.include?(schema) || schema =~ /^pg_/ }

      schemas.each do |schema|
        Ekylibre::Record::Base.connection.execute("DROP SCHEMA #{schema} CASCADE")
      end

      Rake::Task['tenant:clear'].invoke
      Rake::Task['db:migrate'].invoke
    end
  end
end

Rake::Task['db:create'].enhance do
  Rake::Task['db:extensions'].invoke
end

Rake::Task['db:drop'].enhance do
  Rake::Task['tenant:clear'].invoke
end

Rake::Task['db:test:purge'].enhance do
  Rake::Task['db:extensions'].invoke
end<commit_msg>Quote schema name in db:reinit rake task<commit_after>####### Important information ####################
# This file is used to setup a shared extensions #
# within a dedicated schema. This gives us the   #
# advantage of only needing to enable extensions #
# in one place.                                  #
#                                                #
# This task should be run AFTER db:create but    #
# BEFORE db:migrate.                             #
##################################################

namespace :db do
  desc 'Also create shared extensions schemas'
  task extensions: :environment do
    Ekylibre::Schema.setup_extensions
  end

  if Rails.env.development?
    task reinit: :environment do
      Lexicon.disable!

      schema_whitelist = ['information_schema', 'postgis', Lexicon::DISABLED_SCHEMA].freeze
      schemas = Ekylibre::Record::Base.connection
                  .execute("SELECT schema_name FROM information_schema.schemata")
                  .to_a
                  .map { |h| h['schema_name'] }
                  .reject {|schema| schema_whitelist.include?(schema) || schema =~ /^pg_/ }

      schemas.each do |schema|
        Ekylibre::Record::Base.connection.execute("DROP SCHEMA \"#{schema}\" CASCADE")
      end

      Rake::Task['tenant:clear'].invoke
      Rake::Task['db:migrate'].invoke
    end
  end
end

Rake::Task['db:create'].enhance do
  Rake::Task['db:extensions'].invoke
end

Rake::Task['db:drop'].enhance do
  Rake::Task['tenant:clear'].invoke
end

Rake::Task['db:test:purge'].enhance do
  Rake::Task['db:extensions'].invoke
end
{'fraction_non_alphanumeric': 0.1573926868044515, 'fraction_numerical': 0.0, 'mean_word_length': 2.645422943221321, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7191779', 'n_tokens_mistral': 904, 'n_tokens_neox': 883, 'n_words': 217}