forked from Fitchburgh/movielens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
33 lines (29 loc) · 1.2 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
require 'rubygems'
require 'bundler/setup'
require 'active_record'
require 'pg'
require 'yaml'
namespace :db do
desc "Migrate the db"
task :migrate do
# connection_details = YAML::load(File.open('config/database.yml'))
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL']) # connection_details)
ActiveRecord::Migrator.migrate("db/migrate/")
end
desc "Create the db"
task :create do
# connection_details = YAML::load(File.open('config/database.yml'))
admin_connection = ENV['DATABASE_URL'].merge({'database'=> 'postgres',
'schema_search_path'=> 'public'})
ActiveRecord::Base.establish_connection(admin_connection)
ActiveRecord::Base.connection.create_database(ENV['DATABASE_URL'].fetch('database'))
end
desc "drop the db"
task :drop do
# connection_details = YAML::load(File.open('config/database.yml'))
admin_connection = ENV['DATABASE_URL'].merge({'database'=> 'postgres',
'schema_search_path'=> 'public'})
ActiveRecord::Base.establish_connection(admin_connection)
ActiveRecord::Base.connection.drop_database(ENV['DATABASE_URL'].fetch('database'))
end
end