forked from line/promgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
35 lines (31 loc) · 895 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
require 'rake/testtask'
require 'rubocop/rake_task'
require 'logger'
RuboCop::RakeTask.new
task default: [:test]
Rake::TestTask.new do |t|
t.libs << 'test'
t.ruby_opts = ['-r "./test/test_helper"'] if ENV['COVERAGE']
t.test_files = FileList['test/**/test_*.rb']
t.warning = false
t.verbose = false
end
# rake db:migrate
# rake db:migrate[2]
namespace :db do
desc 'Run migrations'
task :migrate, [:version] do |_t, args|
require 'sequel'
Sequel.extension :migration
logger = ENV['LOGGER'] ? Logger.new(STDOUT) : nil
db = Sequel.connect(ENV.fetch('DATABASE_URL'), logger: logger)
if args[:version]
puts "Migrating to version #{args[:version]}"
Sequel::Migrator.run(db, 'migrations', target: args[:version].to_i)
else
puts 'Migrating to latest'
Sequel::Migrator.run(db, 'migrations')
end
end
end