-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
26 lines (20 loc) · 845 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
require 'pg'
task :test_database_setup do
#p "Cleaning database..."
connection = PG.connect(dbname: 'bookmark_manager_test')
# Clear the database
connection.exec("TRUNCATE links;")
# Add the test data
connection.exec("INSERT INTO links VALUES(1, 'http://www.makersacademy.com', 'Makers Academy');")
connection.exec("INSERT INTO links VALUES(2, 'http://www.google.com', 'Google');")
connection.exec("INSERT INTO links VALUES(3, 'http://www.facebook.com', 'Facebook');")
end
task :setup do
p "Creating databases..."
['bookmark_manager', 'bookmark_manager_test'].each do |database|
connection = PG.connect
connection.exec("CREATE DATABASE #{ database };")
connection = PG.connect(dbname: database)
connection.exec("CREATE TABLE links(id SERIAL PRIMARY KEY, url VARCHAR(60), title VARCHAR(60));")
end
end