Refine Your App

OK, enough with the overview. Let’s write some code.

Managing Database Migrations

You’ll notice that the home page of our application instructs us to run lein run migrate in order to initialize the database. This will use the resources/migrations/20150719215253-add-users-table.up.sql file to initialize the database for us. Note that the date on your file will be different since it’s set to the date the application was instantiated.

Since we’re writing a guestbook, let’s delete the current files and add migrations that are appropriate for our application. We can create new migrations by running the following command:

 lein migratus create guestbook

This creates two migration files, one for updating the database and another ...

Get Web Development with Clojure, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.