forked from maccman/go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
37 lines (29 loc) · 957 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
# frozen_string_literal: true
require './app/db.rb'
# Add in migration extension
migration_path = 'app/migrations'
namespace :db do
namespace :migrate do
Sequel.extension(:migration)
desc 'Perform migration reset (full erase and migration up)'
task reset: %i[down up] do
end
desc 'Perform migration up/down to VERSION'
task :to do
raise 'No VERSION was provided' if ENV['VERSION'].nil?
Sequel::Migrator.run(DB, migration_path, target: ENV['VERSION'].to_i)
puts "<= sq:migrate:to version=[#{version}] executed"
end
desc 'Perform migration up to latest migration available'
task :up do
Sequel::Migrator.run(DB, migration_path)
puts '<= sq:migrate:up executed'
end
desc 'Perform migration down (erase all data)'
task :down do
Sequel::Migrator.run(DB, migration_path, target: 0)
puts '<= sq:migrate:down executed'
end
end
task migrate: 'migrate:up'
end