-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
38 lines (34 loc) · 862 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
38
require 'rake'
task :environment do
load 'app.rb'
end
namespace :db do
desc 'Create database'
task create: :environment do
conn = PG::Connection.open(
host: database.opts[:host],
port: database.opts[:port],
user: database.opts[:user],
password: database.opts[:password],
dbname: 'template1'
)
conn.exec "CREATE DATABASE #{database.opts[:database]}"
conn.close
end
desc "Migrate the database"
task migrate: :environment do
Sequel.extension :migration
if ENV['version']
puts "Migrating to version #{ENV['version']}"
Sequel::Migrator.run(database, "db/migrations", target: ENV['version'].to_i)
else
puts 'Migrating to latest'
Sequel::Migrator.run(database, 'db/migrations')
end
end
end
task console: :environment do
require 'irb'
ARGV.clear
IRB.start
end