Scala-Forklift helps manage and apply database migrations for your Scala project.
Write your migrations in plain SQL:
MyMigrations.migrations = MyMigrations.migrations :+ SqlMigration(1)(List( sqlu"""create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR NOT NULL,"last" VARCHAR NOT NULL)""" ))
Or type-safe Slick queries:
MyMigrations.migrations = MyMigrations.migrations :+ DBIOMigration(2)( DBIO.seq(Users ++= Seq( UsersRow(1, "Chris","Vogt"), UsersRow(2, "Yao","Li") )))
Or use slick-migration-api:
MyMigrations.migrations = MyMigrations.migrations :+ APIMigration(3)( TableMigration(Users). renameColumn(_.first, "firstname"). renameColumn(_.last, "lastname"))
APIMigration is not supported in versions prior to
Don't worry about keeping the Scala code and your database schema consistent. Our source code generator will have it generated for you.
- Supports for type-safe database migration with Slick and slick-migration-api.
- A source code generator to generate and manage Scala models from your database schemas.
- A tool to help you manage your dev db with git, with supports for branching and merging.
- High customizability.
How to Use
Scala-Forklift supports both Slick 3.1 and Slick 3.2. The latest versions of Scala-Forklift are given below:
|Scala Version||Slick Version||SBT dependency|
For tutorial and example code, please check example.
Here is also a wonderful tutorial written by Andreas Burkard and Julian Tragé.
You can use our start template on GitHub to quickly start a project with Scala-Forklift:
git clone https://github.com/lastland/scala-forklift-start-template.git
resetcommand may not correctly handle database schemas with foreign keys.