-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRakefile
More file actions
28 lines (24 loc) · 761 Bytes
/
Rakefile
File metadata and controls
28 lines (24 loc) · 761 Bytes
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
begin
require './env'
rescue LoadError
end
namespace :db do
task :environment do
require "./environment"
MIGRATIONS_DIR = ENV['MIGRATIONS_DIR'] || 'db/migrations'
end
desc 'Migrate the database'
task :migrate => :environment do
ActiveRecord::Migration.verbose = true
ActiveRecord::Migrator.migrate MIGRATIONS_DIR, ENV['VERSION'] ? ENV['VERSION'].to_i : nil
end
desc 'Rolls the schema back to the previous version'
task :rollback => :environment do
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
ActiveRecord::Migrator.rollback MIGRATIONS_DIR, step
end
desc "Retrieves the current schema version number"
task :version => :environment do
puts "Current version: #{ActiveRecord::Migrator.current_version}"
end
end