Giter Club home page Giter Club logo

dbrush's Introduction

DB RUSH master Lines of Code Coverage Cats friendly

Super simple pure migration tool for scala

Traditional migration tools such as liquibase or flyway works with externally described migration file.

DB RUSH is a simple library to do migrations right in scala code.

Import:

libraryDependencies ++= Seq(
  "io.github.oybek" % "dbrush" % "0.1"
)

Example:

import doobie._
import doobie.implicits._

lazy val createCity =
  sql"""
       |create table city(
       |  name varchar,
       |  population int not null
       |)
       |""".stripMargin

lazy val createSchool =
  sql"""
       |create table school(
       |  name varchar,
       |  latitude float,
       |  longitude float
       |)
       |""".stripMargin

lazy val createStudent =
  sql"""
       |create table Student(
       |  name varchar,
       |  age int
       |)
       |""".stripMargin

lazy val plugFuzzySearch =
  sql"CREATE EXTENSION fuzzystrmatch"

// Migration list
List(
  Migration("create city", createCity, createSchool),
  Migration("create student", createStudent),
  Migration("plug fuzzy search", plugFuzzySearch)
).exec[IO](transactor) // F[Unit]

Each migration executed within one transaction. Only appends to migration list allowed, otherwise you'll get consistency hash (md5) mismatch at migration phase.

Library creates db_rush_commits for usage:

test_db=# select * from db_rush_commits;
 index |       label       |               md5
-------+-------------------+----------------------------------
     1 | create city       | 6AD188238A2F3B19E0AE1FEBB7383992
     2 | create student    | 26E31E875DB55C8746728D6B789289BE
     3 | plug fuzzy search | 90B3A78FA8FE18CE36EB56F3C3A54494
(3 rows)

Tested under Postgresql:

  • 10.[2-13]
  • 9.6.12

dbrush's People

Contributors

oybek avatar

Stargazers

Kamil Valinurov avatar Anton Voitsishevskii avatar

Watchers

James Cloos avatar  avatar

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.