2016-04-11 16:05:15 +02:00
|
|
|
# frozen_string_literal: true
|
2017-06-14 22:16:21 +02:00
|
|
|
|
2014-03-14 13:12:21 +01:00
|
|
|
namespace :db do
|
|
|
|
desc 'Run database migrations'
|
2014-03-14 13:49:16 +01:00
|
|
|
task migrate: :environment do
|
2014-03-14 13:12:21 +01:00
|
|
|
Sequel.extension(:migration)
|
|
|
|
db = Sequel::DATABASES.first
|
|
|
|
dir = App.root.join('db/migrate')
|
|
|
|
opts = {}
|
|
|
|
opts.update(target: ENV['VERSION'].to_i) if ENV['VERSION']
|
|
|
|
|
|
|
|
Sequel::IntegerMigrator.new(db, dir, opts).run
|
|
|
|
end
|
2018-01-08 13:12:54 +01:00
|
|
|
|
2021-04-25 18:46:58 +02:00
|
|
|
desc 'Run database migrations and seed data'
|
2020-04-02 15:38:07 +02:00
|
|
|
task prepare: %w[db:migrate rates:all]
|
|
|
|
|
|
|
|
namespace :test do
|
2021-04-25 18:46:58 +02:00
|
|
|
desc 'Run database migrations and seed with saved data'
|
2020-04-02 15:38:07 +02:00
|
|
|
task :prepare do
|
|
|
|
ENV['APP_ENV'] ||= 'test'
|
|
|
|
Rake::Task['db:migrate'].invoke
|
|
|
|
Rake::Task['rates:seed_with_saved_data'].invoke
|
|
|
|
end
|
|
|
|
end
|
2014-03-14 13:12:21 +01:00
|
|
|
end
|