-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
60 lines (47 loc) · 1.45 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'sequel'
require 'yaml'
# Load config file
settings = YAML::load(File.open('config.yml'))
namespace :db do
Sequel.extension :migration, :core_extensions
migrator = Sequel::Migrator
migrations = settings['migrations_path']
environment = settings['environment']
env_settngs = settings[environment]
# Setup Database Connection
sqlite_path = env_settngs['sqlite_path']
DB = Sequel.sqlite(sqlite_path)
task :drop do
puts "Reverting all migrations..."
migrator.apply(DB, migrations, 0)
puts "Done!"
end
task :migrate do
puts "Migrating to newest migration..."
migrator.apply(DB, migrations)
puts "Done!"
end
task :reset do
Rake::Task['db:drop'].execute
Rake::Task['db:migrate'].execute
end
task :fake do
puts "Populating database with presentation-ready data..."
require './database/dummy_data_presentation.rb'
puts "Done!"
end
task :dummy do
puts "Populating database with dummy data..."
require './database/dummy_data_population.rb'
puts "Done!"
end
task :help do
puts "Run with rake db:command. Available commands:"
puts "drop - Reverts all migrations"
puts "reset - Reverts all migrations and applies all again"
puts "migrate - Migrates to newest migration"
puts "dummy - Fills the database with dummy data"
puts "fake - Fills the database with presentation-ready dummy data"
puts "help - Prints this help message"
end
end