# frozen_string_literal: true
require "bundler/setup"
# require "bundler/gem_tasks"
require "standalone_migrations"
# # HOTFIX: StandaloneMigrations 7.1.0 uses #exists?, which is removed in 3.2
# # They have yet to patch it 12023-Mar-04
# class File
# class << self
# alias_method :exists?, :exist?
# end
# end
# HOTFIX: StandaloneMigrations honors `schema:` in .standalone_migrations for
# loads but db:schema:dump still reads ENV["SCHEMA"]. Point it at core so the
# dump lands next to the migrations.
ENV["SCHEMA"] = File.join(ENV.fetch("ESM_CORE_PATH"), "db", "schema.rb")
StandaloneMigrations::Tasks.load_tasks
# Must be required AFTER StandaloneMigrations
require_relative "lib/esm"
if ENV["ESM_ENV"] == "test"
require "rspec/core/rake_task"
require "awesome_print"
require "pry"
load "tasks/otr-activerecord.rake"
OTR::ActiveRecord.configure_from_file!(ENV.fetch("ESM_CORE_PATH") + "/config/database.yml")
RSpec::Core::RakeTask.new(:spec)
task default: :spec
end
if ["development", "test"].include?(ENV["ESM_ENV"])
require "standard/rake"
end
Rake.add_rakelib("tasks")
Rake.add_rakelib(ENV.fetch("ESM_CORE_PATH") + "/tasks/migrations")
task default: [:test, "standard:fix"]
task :environment do
ESM.load!
end
task :discord_bot do
ESM.run!(async: true, bare: true)
end