-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
50 lines (40 loc) · 855 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
task default: :test
desc "start app"
task :start do
exec 'shotgun -r pry -o 0.0.0.0'
end
desc "start console"
task :console do
exec 'pry -r./app'
end
desc "run all tests"
task test: ["test:api"]
namespace :test do
task :api do
run "test/api/**/*.rb"
end
end
namespace :db do
desc "load env"
task :environment do
require 'dotenv'
Dotenv.load
require_relative 'config/db'
Sequel.extension :migration
end
desc "version"
task :version => [:environment] do
version = if DB.tables.include?(:schema_info)
DB[:schema_info].first[:version]
end || 0
puts "Schema Version: #{version}"
end
desc "perform migrations"
task :migrate => [:environment] do
Sequel::Migrator.run(DB, 'migrations')
Rake::Task['db:version'].execute
end
end
def run(dir)
Dir[dir].each { |file| load file }
end