Coder Social home page Coder Social logo

scala-forklift's Introduction

Scala-Forklift

Circle CI Join the chat at https://gitter.im/lastland/scala-forklift

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"))

(Note: APIMigration is not supported in versions prior to v0.2.3)

Don't worry about keeping the Scala code and your database schema consistent. Our source code generator will have it generated for you.

Key Features:

  • 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
2.11.x 3.1.x libraryDependencies += "com.liyaos" %% "scala-forklift-slick" % "0.2.3"
2.12.x, 2.11.x 3.2.x libraryDependencies += "com.liyaos" %% "scala-forklift-slick" % "0.3.1"
2.13.x, 2.12.x 3.3.x libraryDependencies += "com.liyaos" %% "scala-forklift-slick" % "0.3.2"

For tutorial and example code, please check example.

Here is also a wonderful tutorial written by Andreas Burkard and Julian Tragé.

Quick Start

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

More Examples

Known Issues

  • The reset command may not correctly handle database schemas with foreign keys.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.