Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 524 lines (394 sloc) 18.302 kb
e5a7224 David E. Wheeler Start sqitchtutorial.
authored
1 =head1 Name
2
3 sqitchtutorial - A tutorial introduction to Sqitch
4
5 =head1 Synopsis
6
7 sqitch *
8
9 =head1 Description
10
11 This tutorial explains how to create a sqitch-enabled project, use a VCS for
12 deployment planning, and work with other developers to make sure changes
13 remain in sync and in the proper order.
14
15 We'll start with a new project, from scratch, a fictional antisocial
16 networking site called Flipr. All examples use L<Git|http://git-scm.com/> as
17 the VCS and L<PostgreSQL|http://www.postgresql.org/> as the storage engine,
18 but for the most part you can substitute other VCSes and database engines in
19 the examples as appropriate.
20
21 =head1 Starting a New Project
22
23 Usually the first thing to do when starting a new project is to create a
24 source code repository. So let's do that with Git:
25
26 > mkdir flipr
27 > cd flipr
28 > git init .
29 Initialized empty Git repository in /flipr/.git/
30 > touch README.md
31 > git add .
32 > git commit -am 'Fist post!'
33
34 If you're a Git user and want to follow along the history, the repository
35 used in these examples is L<on GitHub|https://github.com/theory/sqitch-intro>.
36
37 Now that we have a repository, let's get started with Sqitch.
38
39 > sqitch init --engine pg
40 Created sqitch.ini
41 Created sql/deploy
42 Created sql/revert
43
44 Let's have a look at F<sqitch.ini>:
45
46 [core]
47 engine = pg
48 # sql_dir = sql
49 # extension = sql
50
51 Pretty simple. It picked up on the fact that we're creating changes for the
52 PostgreSQL engine, thanks to the C<--engine pg> option, and saved it to the
53 file. By default, Sqitch will read F<sqitch.ini> in the current directory for
54 settings. But it will also read F<~/.sqitch/config.ini> for global settings.
55 Since PostgreSQL's C<psql> client is not in the path on my system, let's go
56 ahead an tell it globally where to find the client:
57
58 sqitch config --global core.pg.client /var/lib/pgsql/bin/psql
59
60 Have a look at F<~/.sqitch/config.ini> and you'll see this:
61
62 [core.pg]
63 client = /var/lib/pgsql/bin/psql
64
65 Back to the repository. Let's commit these changes and start creating the
66 database changes.
67
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
68 > git add .
69 > git commit -am 'Initialize Sqitch configuration.'
70
71 =head1 Your First Deployment
72
73 First, our project will need a database user. This is the application user,
74 who will have only limited access to objects in the database. Run this command:
75
76 > sqitch add-step appuser
77 Adding sql/deploy/appuser.sql
78 Adding sql/revert/appuser.sql
79
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
80 Now we can edit these files. The C<deploy> script's job is to create the user.
81 So add this to the file:
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
82
83 CREATE ROLE flipr WITH LOGIN;
84
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
85 The C<revert> script's job is to precisely revert the change to the deploy
86 script, like so:
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
87
88 DROP ROLE flipr;
89
90 Now we can try deploying this change:
91
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
92 > sqitch --db-name flipr_test deploy --untracked
93 Adding metadata schema to flipr_test
94 Deploying HEAD+ to flipr_test
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
95 - appuser
96
97 First Sqitch created the metadata schema it uses to track database changes.
98 The structure and name of the metadata may vary between databases (PostgreSQL
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
99 uses a schema to namespace its metadata; MySQL and SQLite use a prefix). Then
100 it deploys changes. Here it is deploying to something called C<HEAD+>.
101 Normally you would see a tag here, but since we've just added the files and
102 they are not yet committed to Git, there is no tag. C<HEAD+> is a special tag
103 reserved for use by Sqitch. It's enabled only by the use of the C<--untracked>
104 option, which allows Sqitch to find an deploy untracked changes.
105
106 With this change deployed, if you connect to the database, you'll be able to
107 see the role:
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
108
109 > psql -d flipr_test -c '\du'
110 List of roles
111 Role name | Attributes | Member of
112 ----------------+------------------------------------------------+-----------
113 flipr | | {}
114 postgres | Superuser, Create role, Create DB, Replication | {}
115
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
116 And we can also see how the deployment was recorded via the C<status> command,
117 which reads the metadata tables from the database:
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
118
119 > sqitch -d flipr_test status
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
120 # Deployed to HEAD+
121 # Step: appuser
122 # Date: 2012-04-09 18:43:45
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
123 #
124 Nothing to deploy (up-to-date)
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
125
126 Let's make sure that we can revert the change, as well:
127
128 > sqitch --db-name flipr_test revert
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
129 Reverting all changes from flipr_test
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
130 - appuser
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
131
132 And now the user should be gone:
133
134 > psql -d flipr_test -c '\du'
135 List of roles
136 Role name | Attributes | Member of
137 ----------------+------------------------------------------------+-----------
138 postgres | Superuser, Create role, Create DB, Replication | {}
139
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
140 And the status message should reflect as much:
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
141
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
142 > sqitch -d flipr_test status --untracked
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
143 # Nothing deployed.
144 #
145 # Changes not yet deployed:
146 # * HEAD+
147 # appuser
148 #
149 Use "sqitch deploy" to deploy these changes
150
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
151 We've again used the C<--untracked> option, otherwise the C<appuser> step would
07542be arhuman Fix (very few) typos in documentation
arhuman authored
152 not appear in the list of undeployed changes.
e41bc5e David E. Wheeler Add example of first deployment to tutorial.
authored
153
07542be arhuman Fix (very few) typos in documentation
arhuman authored
154 We still have a record that the change happened, visible via the C<log>
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
155 command:
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
156
157 > sqitch -d flipr_test log
158 step appuser reverted
159 By: david
160 At: 2012-04-09 18:45:47
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
161 Tag: HEAD+
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
162
163 step appuser deployed
164 By: david
165 At: 2012-04-09 18:43:45
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
166 Tag: HEAD+
b72f83a David E. Wheeler Add a second deployment.
authored
167
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
168 Cool. Now let's commit it.
b72f83a David E. Wheeler Add a second deployment.
authored
169
170 > git add .
171 > git commit -m 'Add app user.'
172 [master 36acafd] Add app user.
173 2 files changed, 2 insertions(+)
174 create mode 100644 sql/deploy/appuser.sql
175 create mode 100644 sql/revert/appuser.sql
176
177 And then deploy again:
178
179 > sqitch --db-name flipr_test deploy
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
180 Deploying 36acafd to flipr_test
b72f83a David E. Wheeler Add a second deployment.
authored
181 - appuser
182
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
183 Notice we no longer need the C<--untracked> option. That's because we've committed
b72f83a David E. Wheeler Add a second deployment.
authored
184 the step to Git, so Sqitch can read it from the Git history. And now the user
185 should be back:
186
187 > psql -d flipr_test -c '\du'
188 List of roles
189 Role name | Attributes | Member of
190 ----------------+------------------------------------------------+-----------
191 flipr | | {}
192 postgres | Superuser, Create role, Create DB, Replication | {}
193
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
194 When we look at the status, the deployment is tagged with the SHA1 of the
b72f83a David E. Wheeler Add a second deployment.
authored
195 commit:
196
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
197 > sqitch -d flipr_test status
198 # Deployed to 36acafd
199 # Step: appuser
200 # Date: 2012-04-09 18:52:42
201 #
202 Nothing to deploy (up-to-date)
b72f83a David E. Wheeler Add a second deployment.
authored
203
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
204 =head1 Deploy with Dependency
b72f83a David E. Wheeler Add a second deployment.
authored
205
206 Let's add another deployment, this time to create a table. Our app will need
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
207 users, of course, so we'll create a table for them. First, add the new step:
b72f83a David E. Wheeler Add a second deployment.
authored
208
209 > sqitch add-step users
210 Adding sql/deploy/users.sql
211 Adding sql/revert/users.sql
212
213 Now edit the scripts. In C<sql/deploy/users.sql>, we put:
214
215 -- requires: appuser
216 BEGIN;
217 SET client_min_messages = 'warning';
218
219 CREATE TABLE users (
220 nickname TEXT PRIMARY KEY,
221 password TEXT NOT NULL,
222 timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
223 );
224
225 GRANT SELECT ON users TO flipr;
226 COMMIT;
227
228 A few things to notice here. On the first line, we've declared a dependency on
229 the C<appuser> step. Although the step has already been added and committed,
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
230 and therefore should always be applied before the C<users> step, it's a good
231 idea to always be explicit about dependencies on other steps. This becomes
232 especially important when committing a number of steps at one time, such as
233 when merging a patch or a branch.
b72f83a David E. Wheeler Add a second deployment.
authored
234
235 The syntax of the dependency declaration is simple: Before any other lines,
236 create an SQL C<--> comment that simply uses the word "requires" followed by a
237 colon and then a comma-delimited list of required steps. The requirements may
238 also be listed on separate lines, providing they all start with
239 C<-- requires:>.
240
241 Notice that all of the SQL code is wrapped in a transaction. This is handy for
242 PostgreSQL deployments, because DDLs are transactional. The upshot is that if
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
243 any part of the deployment fails, the whole step fails. Such may work
244 less-well for database engines that don't support transactional DDLs.
b72f83a David E. Wheeler Add a second deployment.
authored
245
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
246 Just before the commit, the C<GRANT> command grants C<SELECT> access on the
b72f83a David E. Wheeler Add a second deployment.
authored
247 table to the C<flipr> user created in the C<appuser> step. This is why we
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
248 needed to declare the dependency.
b72f83a David E. Wheeler Add a second deployment.
authored
249
250 Now for the revert script. Add this to C<sql/revert/users.sql>:
251
252 DROP TABLE users;
253
254 Couldn't be much simpler, right? Let's deploy this bad boy:
255
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
256 > sqitch --db-name flipr_test deploy --untracked
257 Deploying HEAD+ to flipr_test
b72f83a David E. Wheeler Add a second deployment.
authored
258 - users
259
260 The C<users> table should have been created:
261
262 > psql -d flipr_test -c '\d users'
263 Table "public.users"
264 Column | Type | Modifiers
265 -----------+--------------------------+------------------------
266 nickname | text | not null
267 password | text | not null
268 timestamp | timestamp with time zone | not null default now()
269 Indexes:
270 "users_pkey" PRIMARY KEY, btree (nickname)
271
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
272 Now have a look at the status:
b72f83a David E. Wheeler Add a second deployment.
authored
273
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
274 > sqitch -d flipr_test status
275 # Deployed to HEAD+
276 # Step: users
277 # Date: 012-04-09 20:41:31
278 #
279 Nothing to deploy (up-to-date)
b72f83a David E. Wheeler Add a second deployment.
authored
280
07542be arhuman Fix (very few) typos in documentation
arhuman authored
281 Success! However, we've once again deployed an untracked change with no tags.
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
282 In general, we want tags, so let's revert the change:
b72f83a David E. Wheeler Add a second deployment.
authored
283
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
284 > sqitch --db-name flipr_test revert --to 36acafd
285 Reverting HEAD+ from flipr_test
b72f83a David E. Wheeler Add a second deployment.
authored
286 - users
287
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
288 Note that we've used the C<--to> option to revert only to the C<36acafd> tag,
289 which represents the deployment of the C<appuser> step (visible via
290 C<sqitch log>). Now commit and deploy again:
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
291
b72f83a David E. Wheeler Add a second deployment.
authored
292 > git add .
293 > git commit -am 'Add users table.'
294 [master fa650af] Add users table.
295 2 files changed, 16 insertions(+)
296 create mode 100644 sql/deploy/users.sql
297 create mode 100644 sql/revert/users.sql
298 > sqitch -d flipr_test deploy
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
299 Deploying fa650af to flipr_test
b72f83a David E. Wheeler Add a second deployment.
authored
300 - users
301
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
302 Looks good. Check the status:
303
304 > sqitch status
305 # Deployed to fa650af
306 # Step: users
307 # Date: 012-04-09 20:45:23
308 #
309 Nothing to deploy (up-to-date)
b72f83a David E. Wheeler Add a second deployment.
authored
310
b67fb66 David E. Wheeler Use `status` and `log` commands instead of table output.
authored
311 Success!
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
312
313 =head1 Add Two at Once
314
315 Let's add a few more deployments that add functions for managing users.
b72f83a David E. Wheeler Add a second deployment.
authored
316
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
317 > sqitch add-step insert_user --requires users --requires appuser
318 Adding sql/deploy/insert_user.sql
319 -- requires: users, appuser
320 Adding sql/revert/insert_user.sql
321
322 > sqitch add-step change_pass --requires users --requires appuser
323 Adding sql/deploy/change_pass.sql
324 -- requires: users, appuser
325 Adding sql/revert/change_pass.sql
326
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
327 Here we've taken advantage of the C<--requires> option to have Sqitch write
328 the deploy file with the C<-- requires:> line already filled in. Have a look:
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
329
330 > cat sql/deploy/insert_user.sql
331 -- requires: users, appuser
332
333
334 Nice, huh? Yeah, okay, so it's a little thing. Little things matter, no? Let's
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
335 write the code. Here's what C<sql/deploy/insert_user.sql> should look like:
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
336
337 -- requires: users, appuser
338
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
339 BEGIN;
340
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
341 CREATE OR REPLACE FUNCTION insert_user(
342 nickname TEXT,
343 password TEXT
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
344 ) RETURNS VOID LANGUAGE SQL SECURITY DEFINER AS $$
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
345 INSERT INTO users values($1, md5($2));
346 $$;
347
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
348 GRANT EXECUTE ON insert_user(TEXT, TEXT) to flipr;
349 COMMIT;
350
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
351 And C<sql/revert/insert_user.sql> should look something like this:
352
353 DROP FUNCTION insert_user(TEXT, TEXT);
354
355 Now for C<change_pass>; C<sql/deploy/change_pass.sql> might look like this:
356
357 -- requires: users, appuser
358
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
359 BEGIN;
360
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
361 CREATE OR REPLACE FUNCTION change_pass(
362 nick TEXT,
363 oldpass TEXT,
364 newpass TEXT
365 ) RETURNS BOOLEAN LANGUAGE plpgsql AS $$
366 BEGIN
367 UPDATE users
368 SET password = md5($3)
369 WHERE nickname = $1
370 AND password = md5($2);
371 RETURN FOUND;
372 END;
373 $$;
374
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
375 GRANT EXECUTE ON chnage_pass(TEXT, TEXT, TEXT) to flipr;
376 COMMIT;
377
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
378 And of course, its reversion script, C<sql/revert/change_pass.sql> should look
379 something like:
380
381 DROP FUNCTION change_pass(TEXT, TEXT, TEXT);
382
383 Test em out!
384
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
385 > sqitch --db-name flipr_test deploy --untracked
386 Deploying HEAD+ to flipr_test
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
387 - change_pass
388 - insert_user
389
390 Do we have the functions?
391
392 > psql -d flipr_test -c '\df'
393 List of functions
394 Schema | Name | Result data type | Argument data types | Type
395 --------+-------------+------------------+---------------------------------------+--------
396 public | change_pass | boolean | nick text, oldpass text, newpass text | normal
397 public | insert_user | void | nickname text, password text | normal
398
399 Is the state set properly?
400
401 > psql -d flipr_test -c 'SELECT * FROM sqitch.state ORDER BY deployed_at'
402 step | deployed_by | tags | requires | conflicts | deployed_at
403 -------------+-------------+-----------+-----------------+-----------+-------------------------------
404 appuser | david | {36acafd} | {} | {} | 2012-04-09 19:04:50.115235+00
405 users | david | {fa650af} | {appuser} | {} | 2012-04-09 20:45:23.848563+00
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
406 change_pass | david | {""} | {appuser,users} | {} | 2012-04-09 21:31:41.952779+00
407 insert_user | david | {""} | {appuser,users} | {} | 2012-04-09 21:31:42.137245+00
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
408
409 Looks good. Let's revert, commit, and re-deploy, as usual.
410
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
411 > sqitch --db-name flipr_test revert --to ^
412 Reverting HEAD+ from flipr_test
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
413 - insert_user
414 - change_pass
415
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
416 Note the use of C<--to ^> to revert one tag. We also could have explicitly
417 used C<--to fa650af> to revert to that tag, but C<^> is a nice shortcut.
418 (Technially, it's actually C<""^>, which means "before the C<""> tag." But
419 don't let that bother you.). Let's do the commit and re-deploy dance:
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
420
421 > git add .
422 > git ci -m 'Add `insert_user()` and `change_pass()`.'
423 [master 803e6b8] Add `insert_user()` and `change_pass()`.
424 4 files changed, 25 insertions(+)
425 create mode 100644 sql/deploy/change_pass.sql
426 create mode 100644 sql/deploy/insert_user.sql
427 create mode 100644 sql/revert/change_pass.sql
428 create mode 100644 sql/revert/insert_user.sql
429
430 > sqitch --db-name flipr_test deploy
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
431 Deploying 803e6b8 to flipr_test
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
432 - change_pass
433 - insert_user
434
435 > psql -d flipr_test -c 'SELECT * FROM sqitch.state ORDER BY deployed_at'
436 step | deployed_by | tags | requires | conflicts | deployed_at
437 -------------+-------------+-----------+-----------------+-----------+-------------------------------
438 appuser | david | {36acafd} | {} | {} | 2012-04-09 19:04:50.115235+00
439 users | david | {fa650af} | {appuser} | {} | 2012-04-09 20:45:23.848563+00
440 change_pass | david | {803e6b8} | {appuser,users} | {} | 2012-04-09 21:33:32.385953+00
441 insert_user | david | {803e6b8} | {appuser,users} | {} | 2012-04-09 21:33:32.830234+00
442
443 =head1 Ship It!
444
445 Let's do a first release of our app. Let's call it C<1.0.0-dev1> Since we want
446 to have it go out with deployments tied to the release, let's tag it:
447
448 > git tag v1.0.0-dev1 -am 'Tag v1.0.0-dev1'
449
450 We can test deployment to make sure the tag gets picked up like so:
451
452 > createdb flipr_dev
453 > sqitch --db-name flipr_dev deploy
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
454 Deploying 36acafd/v1.0.0-dev1 to flipr_dev
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
455 - appuser
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
456 Deploying fa650af/v1.0.0-dev1 to flipr_dev
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
457 - users
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
458 Deploying 803e6b8/v1.0.0-dev1 to flipr_dev
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
459 - insert_user
460 - change_pass
461
462 All four steps were deployed, great! Let's have a look at the state:
463
464 > psql -d flipr_dev -c 'SELECT * FROM sqitch.state ORDER BY deployed_at'
465 step | deployed_by | tags | requires | conflicts | deployed_at
466 -------------+-------------+-----------------------+-----------------+-----------+-------------------------------
467 appuser | david | {36acafd,v1.0.0-dev1} | {} | {} | 2012-04-09 22:13:53.383434+00
468 users | david | {fa650af,v1.0.0-dev1} | {appuser} | {} | 2012-04-09 22:13:55.594923+00
469 insert_user | david | {803e6b8,v1.0.0-dev1} | {appuser,users} | {} | 2012-04-09 22:13:59.253434+00
470 change_pass | david | {803e6b8,v1.0.0-dev1} | {appuser,users} | {} | 2012-04-09 22:14:00.854345+00
471
472 Note that teach step now has the commit SHA1 for a tag I<and> the
473 C<v1.0.0-dev1> tag. This is great, because now we can tie all the steps to the
474 release via the tag. So let's bundle it up.
475
476 > sqitch bundle --tags-only
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
477 Writint to in bundle/
478 Bundling v1.0.0-dev1
479 - appuser
480 - users
481 - change_pass
482 - insert_user
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
483 Plan written to bundle/sqitch.plan
484
485 Now you can package up the C<bundle> directory and distribute it. When it gets
486 installed somewhere, you can use Sqitch to deploy to the database. Of course,
487 the Git history is no longer available, so Sqitch will use the C<sqitch.plan>
488 file to figure things out. Let's have a look at it:
489
490 cat bundle/sqitch.plan
491
492 [v1.0.0-dev1]
493 appuser
494 users
495 change_pass
496 insert_user
497
498 Pretty simple. It shows the tag being deployed and the steps that constitute
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
499 it as a simple list. Notice that the SHA1s for each step are not present; the
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
500 C<--tags-only> option to the C<bundle> command limits the plan only to tags.
501
502 Let's test deploying it:
503
504 > cd bundle
505 > createdb flipr_prod
506 > sqitch --db-name flipr_prod deploy
54bf216 David E. Wheeler Better empty tags; show status and log.
authored
507 Deploying v1.0.0-dev1 to flipr_prod
0ef5586 David E. Wheeler Add more deploys and bundle.
authored
508 - appuser
509 - users
510 - insert_user
511 - change_pass
512
513 Looks much the same as before, eh? But have a look at the state:
514
515 > psql -d flipr_prod -c 'SELECT * FROM sqitch.state ORDER BY deployed_at'
516 step | deployed_by | tags | requires | conflicts | deployed_at
517 -------------+-------------+---------------+-----------------+-----------+-------------------------------
518 appuser | david | {v1.0.0-dev1} | {} | {} | 2012-04-09 22:17:23.934343+00
519 users | david | {v1.0.0-dev1} | {appuser} | {} | 2012-04-09 22:17:25.343254+00
520 insert_user | david | {v1.0.0-dev1} | {appuser,users} | {} | 2012-04-09 22:17:36.235544+00
521 change_pass | david | {v1.0.0-dev1} | {appuser,users} | {} | 2012-04-09 22:17:38.377565+00
522
523 No SHA1 tags, just C<v1.0.0-dev1>.
Something went wrong with that request. Please try again.