GithubHelp home page GithubHelp logo

kuguobing / dropwizard-flyway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dropwizard/dropwizard-flyway

0.0 1.0 0.0 685 KB

Addon bundle for Dropwizard to support Flyway for database migrations

Home Page: https://dropwizard.github.io/dropwizard-flyway/

License: Apache License 2.0

Java 100.00%

dropwizard-flyway's Introduction

Dropwizard Flyway

Build Status Coverage Status

dropwizard-flyway is a set of commands using Flyway for database migrations in Dropwizard applications.

Usage

Just add the FlywayBundle to your Dropwizard application inside the Application#initialize method.

@Override
public void initialize(Bootstrap<MyConfiguration> bootstrap) {
    // ...
    bootstrap.addBundle(new FlywayBundle<MyConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(MyConfiguration configuration) {
            return configuration.getDataSourceFactory();
        }
        
        @Override
        public FlywayFactory getFlywayFactory(MyConfiguration configuration) {
            return configuration.getFlywayFactory();
        }
    });
}

After that you can use one of the following Flyway commands:

Command Description
db migrate Migrates the database
db clean Drops all objects in the configured schemas
db info Prints the details and status information about all the migrations
db validate Validates the applied migrations against the ones available on the classpath
db init Creates and initializes the metadata table (existing database)
db repair Repairs the metadata table

The Flyway migrations must be accessible in the classpath under db/migration (or any other path configured with the locations parameter, see FlywayFactory).

Configuration

dropwizard-flyway is using the standard DataSourceFactory from dropwizard-db for configuring its DataSource.

Additionally you can override the following configuration settings of Flyway using FlywayFactory:

flyway:
  # The encoding of SQL migrations. (default: UTF-8) 
  encoding: UTF-8
  # The schemas managed by Flyway. (default: default schema of the connection)
  schemas:
  # The fully qualified class names of the callbacks for lifecycle notifications. (default: empty list)
  callbacks:
  # The name of the schema metadata table that will be used by Flyway. (default: schema_version)
  metaDataTableName: schema_version
  # The file name prefix for sql migrations (default: V)
  sqlMigrationPrefix: V
  # The file name separator for sql migrations (default: __)
  sqlMigrationSeparator: __
  # The file name suffix for sql migrations (default: .sql)
  sqlMigrationSuffix: .sql
  # The prefix of every placeholder. (default: ${ )
  placeholderPrefix: ${
  # The suffix of every placeholder. (default: } )
  placeholderSuffix: }
  # The map of <placeholder, replacementValue> to apply to sql migration scripts. (default: empty map)
  placeholders:
  # Locations to scan recursively for migrations. (default: db/migration)
  locations:
    - db/migration
  # The fully qualified class names of the custom MigrationResolvers to be used in addition to the built-in ones for resolving Migrations to apply. (default: empty list)
  resolvers:

Maven Artifacts

This project is available on Maven Central. To add it to your project simply add the following dependencies to your pom.xml:

<dependency>
  <groupId>io.dropwizard.modules</groupId>
  <artifactId>dropwizard-flyway</artifactId>
  <version>0.7.0-1</version>
</dependency>

Support

Please file bug reports and feature requests in GitHub issues.

License

Copyright (c) 2014 Jochen Schalanda

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.

dropwizard-flyway's People

Contributors

joschi avatar

Watchers

库国兵 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.