forked from mvemjsun/mock_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
44 lines (36 loc) · 1.18 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
39
40
41
42
43
44
require 'active_record'
require 'yaml'
require 'logger'
require 'cucumber/rake/task'
require 'sqlite3'
namespace :db do
def create_my_database
p "Create DB"
end
task :configure do
p "Task Reading configuration ..."
@config = YAML.load_file('config/database.yml')['development']
end
task :connect_to_db do
p "Task Establishing connection ..."
ActiveRecord::Base.establish_connection @config
ActiveRecord::Base.logger = Logger.new(File.open('logs/migrations.log', 'a'))
end
task :migrate => [:configure, :connect_to_db] do
p "Task Migrate ..."
ActiveRecord::Migration.verbose = true
x=ENV['VERSION'] || '1';
p "Migration version #{x}"
ActiveRecord::Migrator.migrate './db/migrations', ENV['VERSION'] ? ENV['VERSION'].to_i : nil
end
task :rollback => [:configure, :connect_to_db] do
# Default rollback to 1 step if STEP not specified in rake command
rollback_steps = ENV['STEPS'] ? ENV['STEPS'].to_i : 1
p "Rollback by #{rollback_steps} step(s)"
ActiveRecord::Migrator.rollback './db/migrations', rollback_steps
end
task :prepare => [:configure, :connect_to_db] do
p 'Populating initial data.'
# make_users
end
end