<commit_before>namespace :db do
  require 'bundler'
  Bundler.require
  require_relative '../db/config'
  require_relative '../db/connection'
  DB::Connection.establish

  desc "migrate your database"
  task :migrate do
    ActiveRecord::Migrator.migrate('./db/migrate')
  end

  task :rollback do
    step = ENV['STEP'] ? ENV['STEP'].to_i : 1
    ActiveRecord::Migrator.rollback('./db/migrate', step)
  end

  namespace :migrate do
    task :down do
      version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
      raise 'VERSION is required - To go down one migration, run db:rollback' unless version
      ActiveRecord::Migrator.run(:down, './db/migrate', version)
    end
  end

  desc "set up your database"
  task :setup do
    config = DB::Config.new
    sql = "CREATE USER #{config.username} PASSWORD '#{config.password}' " \
          'SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN'
    system 'psql', '-h', config.host, '-c', sql
    system 'createdb', '-h', config.host, '-O', config.username, config.database
  end

  desc "drop and recreate your database"
  task :reset do
    config = DB::Config.new
    system 'dropdb', '-h', config.host, config.database
    system 'createdb', '-h', config.host, '-O', config.username, config.database
  end

  desc 'set the database up from scratch'
  task from_scratch: %i(setup migrate seeds:fetch seed)<commit_msg>Created create and drop db rake tasks<commit_after>namespace :db do
  require 'bundler'
  Bundler.require
  require_relative '../db/config'
  require_relative '../db/connection'
  DB::Connection.establish

  desc "migrate your database"
  task :migrate do
    ActiveRecord::Migrator.migrate('./db/migrate')
  end

  task :rollback do
    step = ENV['STEP'] ? ENV['STEP'].to_i : 1
    ActiveRecord::Migrator.rollback('./db/migrate', step)
  end

  namespace :migrate do
    task :down do
      version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
      raise 'VERSION is required - To go down one migration, run db:rollback' unless version
      ActiveRecord::Migrator.run(:down, './db/migrate', version)
    end
  end

  desc "set up your database"
  task :setup do
    config = DB::Config.new
    sql = "CREATE USER #{config.username} PASSWORD '#{config.password}' " \
          'SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN'
    system 'psql', '-h', config.host, '-c', sql
    system 'createdb', '-h', config.host, '-O', config.username, config.database
  end

  desc "drop and recreate your database"
  task :reset do
    config = DB::Config.new
    system 'dropdb', '-h', config.host, config.database
    system 'createdb', '-h', config.host, '-O', config.username, config.database
  end

  desc "drop your databas"
  task :drop do
    config = DB::Config.new
    system 'dropdb', '-h', config.host, config.database
  end

  desc "create your database"
  task :create do
    config = DB::Config.new
    system 'createdb', '-h', config.host, '-O', config.username, config.database
  end

  desc 'set the database up from scratch'
  task from_scratch: %i(setup migrate seeds:fetch seed)
{'fraction_non_alphanumeric': 0.13302752293577982, 'fraction_numerical': 0.000655307994757536, 'mean_word_length': 3.367668097281831, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2801068', 'n_tokens_mistral': 991, 'n_tokens_neox': 979, 'n_words': 297}