The particular
rake task discussed here, db:migrate, uses migrations to either upgrade or downgrade a database. You
can find a list of all of the tasks available for a Rails application by running the command rake -T.
Adding the Data
Now that you have a Rails application that can connect to your database and a database
structure, you need to fill the database with some data. You can use the SQL code in
Listing 5-3 to do just that.
Listing 5-3. Sample Data for the Actor Scheduling Application (actor_schedule_data.sql)
DELETE FROM actors;
DELETE FROM projects;
DELETE FROM rooms;
DELETE FROM bookings;
INSERT INTO actors (id, name) VALUES
(1, 'Jim Thompson');
INSERT INTO actors (id, name) VALUES
(2, 'Becky Leuser');
INSERT INTO actors (id, name) VALUES
(3, 'Elizabeth Berube');
INSERT INTO actors (id, name) VALUES
(4, 'Dave Guuseman');
INSERT INTO actors (id, name) VALUES
(5, 'Tom Jimson');
INSERT INTO projects (id, name) VALUES
(1, 'Turbo Bowling Intro Sequence');
INSERT INTO projects (id, name) VALUES
(2, 'Seven for Dinner Win Game Sequence');
INSERT INTO projects (id, name) VALUES
(3, 'Seven for Dinner Lost Game Sequence');
CHAPTER 5 n CONNECTING YOUR REPORTS TO THE WORLD 81
INSERT INTO rooms (id, name) VALUES
(1, 'L120, Little Hall');
INSERT INTO rooms (id, name) VALUES
(2, 'L112, Little Hall');
INSERT INTO rooms (id, name) VALUES
(3, 'M120, Tech Center');
INSERT INTO bookings (actor_id, room_id, project_id, booked_at) VALUES
(1,1,2, DATE_ADD( NOW(), INTERVAL 3 HOUR ));
INSERT INTO bookings (actor_id, room_id, project_id, booked_at) VALUES
(1,1,3, DATE_ADD( NOW(), INTERVAL 4 HOUR ));
INSERT INTO bookings (actor_id, room_id, project_id, booked_at) VALUES
(3,2,2, DATE_ADD( NOW(), INTERVAL 1 DAY ));
INSERT INTO bookings (actor_id, room_id, project_id, booked_at) VALUES
(2,3,1, DATE_ADD( NOW(), INTERVAL 5 HOUR ));
Save Listing 5-3 as actor_schedule_data.
Pages:
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134