<commit_before>
# we utilize PostgreSQL's schemas for segmenting our projects within the same database, this works with Heroku Postgres

namespace :db do

  def using_postgres?
    defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
  end

  desc 'Create schemas for Goji Labs PostgreSQL project'
  task :create_schemas => :environment  do
    if using_postgres?
      ActiveRecord::Base.connection.execute "CREATE SCHEMA IF NOT EXISTS #{GojiLabs.project_name}"
      ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
      ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
      ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
    else
      puts "Not using PostgreSQL in this project, refusing to create schemas..."
    end
  end
end

Rake::Task["db:test:purge"].enhance do
  Rake::Task["db:create_schemas"].invoke
end

Rake::Task["db:create"].enhance do
  Rake::Task["db:create_schemas"].invoke if using_postgres?
end

Rake::Task["db:migrate"].enhance do
  Rake::Task["db:create_schemas"].invoke if using_postgres?
end<commit_msg>Add task for removing db schema<commit_after>
# we utilize PostgreSQL's schemas for segmenting our projects within the same database, this works with Heroku Postgres

namespace :db do

  def using_postgres?
    defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
  end

  desc 'Create schemas for Goji Labs PostgreSQL project'
  task create_schema: :environment  do
    if using_postgres?
      ActiveRecord::Base.connection.execute "CREATE SCHEMA IF NOT EXISTS #{GojiLabs.project_name}"
      ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
      ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
      ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
    else
      puts "Not using PostgreSQL in this project, refusing to create schemas..."
    end
  end

  task drop_schema: :environment do
    if using_postgres?
      ActiveRecord::Base.connection.execute "DROP SCHEMA IF EXISTS #{GojiLabs.project_name}"
    end
  end
end

Rake::Task["db:test:purge"].enhance do
  Rake::Task["db:create_schema"].invoke
end

Rake::Task["db:create"].enhance do
  Rake::Task["db:create_schema"].invoke if using_postgres?
end

Rake::Task["db:migrate"].enhance do
  Rake::Task["db:create_schema"].invoke if using_postgres?
end
{'fraction_non_alphanumeric': 0.09228971962616822, 'fraction_numerical': 0.0, 'mean_word_length': 5.073286052009457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2177324', 'n_tokens_mistral': 800, 'n_tokens_neox': 779, 'n_words': 222}