44 lines
1.0 KiB
Ruby
44 lines
1.0 KiB
Ruby
require "minitest/test_task"
|
|
|
|
Minitest::TestTask.create(:test) do |t|
|
|
t.libs << "test"
|
|
t.libs << "src"
|
|
t.warning = false
|
|
t.test_globs = ["test/**/*_test.rb"]
|
|
end
|
|
|
|
task :default => :test
|
|
|
|
require "dotenv"
|
|
require "logger"
|
|
|
|
namespace :db do
|
|
desc "Run migrations"
|
|
task :migrate, [:version] do |t, args|
|
|
require "sequel/core"
|
|
Dotenv.load!(".env")
|
|
Sequel.extension :migration
|
|
version = args[:version].to_i if args[:version]
|
|
Sequel.connect(ENV.fetch("DATABASE_URL"), logger: Logger.new($stderr)) do |db|
|
|
Sequel::Migrator.run(db, "migrations", target: version)
|
|
end
|
|
end
|
|
|
|
# desc "Install default database"
|
|
# task :seed do
|
|
# require "sequel/core"
|
|
# Dotenv.load!(".env")
|
|
# Sequel.connect(ENV.fetch("DATABASE_URL"), logger: Logger.new($stderr)) do |db|
|
|
# db[:campaigns].insert(name: "Etoile Rouge")
|
|
# end
|
|
# end
|
|
end
|
|
|
|
# desc "Reset all tables, schema, data"
|
|
# task "reset" do
|
|
# require_relative "./bin/load_env"
|
|
# DB.tables.each {|t| DB.drop_table t }
|
|
# end
|
|
|
|
task default: :test
|