-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
38 lines (34 loc) · 1.13 KB
/
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
require 'bundler/setup'
require 'rake'
$LOAD_PATH << File.expand_path('../lib', __FILE__)
require 'travis/test-results.rb'
require 'travis/support'
require 'travis/test-results/helpers/database'
namespace :db do
desc 'Apply migrations'
task :migrate, [:version] do |_t, args|
Sequel.extension(:migration)
db = Travis::TestResults::Helpers::Database.create_sequel
if args[:version]
puts "Migrating to version #{args[:version]}"
Sequel::Migrator.run(db, 'db/migrations', target: args[:version].to_i)
else
puts 'Migrating to latest'
Sequel::Migrator.run(db, 'db/migrations')
end
end
desc 'List status for migrations'
task :status do
Sequel.extension(:migration)
db = Travis::TestResults::Helpers::Database.create_sequel
applied = Sequel::TimestampMigrator.new(db, 'db/migrations').applied_migrations
all_migrations = Dir['db/migrations/*.rb'].map { |file| File.basename(file) }.sort
all_migrations.each do |migration_file|
if applied.include?(migration_file)
puts " up #{migration_file}"
else
puts " down #{migration_file}"
end
end
end
end