Squeryl doesn't do database migration for us. This means that you can use the create
method from the schema
object only once, because it tries to create all of the tables each time it runs and it will give errors when trying to create a table that already exists.
For this reason, we can use third-party tools such as Liquibase, in order to automate the migration process; that is, database creation and changing. Liquibase uses an XML file, databaseChangeLog
, to define all of the changes that it needs to execute. Each one of these changes is defined by a changeSet
tag. It also keeps track of these changeSet
tags to prevent executing any one of them twice.
Once you define your databaseChangeLog
file—the XML file that contains the changeSet
tags—you can tell Lift to execute it during application startup. So, whenever you change your database, all you need to do is to create the changeSet
tags, add them into the changelog
file and during the next deployment...