<commit_before>namespace :cartodb do
  namespace :db do
    task :create, [:env] do |_t, args|
      # When the db:create task runs, there is no prior database. Since we use models in our initializers, we need to
      # skip the :environment dependency or Sequel will error out when trying to load the schema for the model table.
      # This task overrides the default Sequel task, loading the bare minimum (db config) instead of all initializers
      args.with_defaults(:env => Rails.env)

      config = SequelRails::Configuration.for(Rails.root, Carto::Conf.new.db_config)

      unless SequelRails::Storage.create_environment(config.environment_for(args.env))
        abort "Could not create database for #{args.env}."
      end
    end
  end

  namespace :test do
    task :prepare do
      if (ENV['RAILS_ENV'] == "test")
        begin
          Rake::Task['db:drop'].invoke
        rescue Sequel::DatabaseConnectionError
          puts "Not dropping DB (did not exist)"
        end
        Rake::Task['db:create'].invoke &&
        Rake::Task['db:migrate'].invoke &&
        Rake::Task['cartodb:db:create_publicuser'].invoke
      else
        system("rake cartodb:test:prepare RAILS_ENV=test") || raise("Something went wrong")
      end
    end
  end
  namespace :db do
    desc <<-DESC
Setup cartodb database and creates a new user from environment variables:
  - ENV['EMAIL']: user e-mail
  - ENV['PASSWORD']: <PASSWORD><commit_msg>Update setup.rake<commit_after>namespace :cartodb do
  namespace :db do
    task :create, [:env] do |_t, args|
      # When the db:create task runs, there is no prior database. Since we use models in our initializers, we need to
      # skip the :environment dependency or Sequel will error out when trying to load the schema for the model table.
      # This task overrides the default Sequel task, loading the bare minimum (db config) instead of all initializers
      args.with_defaults(env: Rails.env)

      config = SequelRails::Configuration.for(Rails.root, Carto::Conf.new.db_config)

      unless SequelRails::Storage.create_environment(config.environment_for(args.env))
        abort "Could not create database for #{args.env}."
      end
    end
  end

  namespace :test do
    task :prepare do
      if (ENV['RAILS_ENV'] == "test")
        begin
          Rake::Task['db:drop'].invoke
        rescue Sequel::DatabaseConnectionError
          puts "Not dropping DB (did not exist)"
        end
        Rake::Task['db:create'].invoke &&
        Rake::Task['db:migrate'].invoke &&
        Rake::Task['cartodb:db:create_publicuser'].invoke
      else
        system("rake cartodb:test:prepare RAILS_ENV=test") || raise("Something went wrong")
      end
    end
  end
  namespace :db do
    desc <<-DESC
Setup cartodb database and creates a new user from environment variables:
  - ENV['EMAIL']: user e-mail
  - ENV['PASSWORD']: <PASSWORD>
{'fraction_non_alphanumeric': 0.10204081632653061, 'fraction_numerical': 0.0, 'mean_word_length': 3.096317280453258, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, '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': '2716995', 'n_tokens_mistral': 841, 'n_tokens_neox': 832, 'n_words': 280}