Giter VIP home page Giter VIP logo

play-flyway's Introduction

play-flyway

Flyway plugin for Play 2.1. It aims to be a substitute for play-evolutions.

Features

  • Based on Flyway
  • No 'Downs' part.
  • Independent of DBPlugin(play.api.db).

Install

For Play 2.2.x

In Build.scala/build.sbt

libraryDependencies += "com.github.tototoshi" %% "play-flyway" % "1.0.3"

and write play.plugins.

1000:com.github.tototoshi.play2.flyway.Plugin

For Play 2.1.x

In Build.scala/build.sbt

libraryDependencies += "com.github.tototoshi" %% "play-flyway" % "0.2.0"

and write play.plugins.

1000:com.github.tototoshi.play2.flyway.Plugin

Usage

Sample

seratch/devteam-app is using play-flyway. Maybe this is a good example.

Place migration scripts

A migration script is just a simple SQL file.

CREATE TABLE FOO (.............

Place your migration scripts in conf/db/migration/${dbName} .

playapp
├── app
│   ├── controllers
│   ├── models
│   └── views
├── conf
│   ├── application.conf
│   ├── db
│   │   └── migration
│   │       ├── default
│   │       │   ├── V1__Create_person_table.sql
│   │       │   └── V2__Add_people.sql
│   │       └── secondary
│   │           ├── V1__create_job_table.sql
│   │           └── V2__Add_job.sql
│   ├── play.plugins
│   └── routes

Please see flyway's documents about the naming convention for migration scripts.

http://flywaydb.org/documentation/migration/sql.html

Dev

screenshot

For existing schema, Flyway has a option called 'initOnMigrate'. This option is enabled when -Ddb.${dbName}.migration.initOnMigrate=true. For example,

$ play -Ddb.default.migration.initOnMigrate=true

Of course, You can write this in your application.conf.

Manual migration is also supported. Click 'Other operations' or open /@flyway/${dbName} directly.

screenshot

Test

In Test mode, migration is done automatically.

Prod

In production mode, migration is done automatically if db.${dbName}.migration.auto is set to be true in application.conf. Otherwise it failed to start when migration is needed.

$ play -Ddb.default.migration.auto=true start

Change Log

1.0.3

  • Disable the plugin when flywayplugin=disabled is found in application.conf.

1.0.2

  • Fixed #7: Reading "db.${dbName}.password", but not "db.${dbName}.pass"

1.0.1

  • Supports reading the driver configuration parameter from Play2 config.
  • Updated flyway to 2.3.

play-flyway's People

Contributors

k4200 avatar markterm avatar tototoshi avatar

Watchers

 avatar  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.