Giter Club home page Giter Club logo

sbt-pillar-plugin's Introduction

sbt-pillar - manage Cassandra migrations from sbt

Build Status Codacy Badge Codacy Badge

A rewrite of the plugin https://github.com/inoio/sbt-pillar-plugin and added:

  • Allow use of Authentication credentials.
  • Allow passing in hosts as a comma-separated string.
  • Allow creating of cql migration files.
  • Will allow use of NetworkTopologyStrategy for creating keyspaces.

This sbt plugin enables running Cassandra schema/data migrations from sbt (using pillar). For details on migration files check out the pillar documentation.

The plugin is built for sbt 0.13.6+.

Installation

To install the plugin you have to add it to project/plugins.sbt:

addSbtPlugin("io.github.henders" %% "sbt-pillar" % "0.1.7")

Configuration

Add appropriate configuration to build.sbt like this:

pillarConfigFile in ThisBuild := file("db/pillar.conf")
pillarMigrationsDir in ThisBuild := file("db/migrations")

The shown configuration assumes that the settings for your cassandra are configured in db/pillar.conf and that pillar migration files are kept in db/migrations (regarding the format of migration files check out the pillar documentation).

An example configuration file (based on typesafe-config) is:

development {
  cassandra {
    keyspace = "pigeon"
    hosts = "localhost"
    port = 9042
    replicationFactor = 1
    defaultConsistencyLevel = 1
    replicationStrategy = "SimpleStrategy"
  }
}

test = ${development}
test {
  cassandra {
    keyspace = "pigeon_test"
  }
}

master {
  cassandra {
    hosts = ${?CASSANDRA_HOSTS}
    port = 9042
    keyspace = ${?CASSANDRA_KEYSPACE}
    username = ${?CASSANDRA_USERNAME}
    password = ${?CASSANDRA_PASSWORD}
    replicationFactor = ${?CASSANDRA_REPLICATION_FACTOR}
    defaultConsistencyLevel = ${?CASSANDRA_CONSISTENCY_LEVEL}
    replicationStrategy = "SimpleStrategy"
  }
}

staging = ${master}
production = ${master}

Usage

The sbt pillar plugin provides the following tasks:

createKeyspace
Creates the keyspace (and creates pillar's applied_migrations table)
dropKeyspace
Drops the keyspace
migrate
Runs pillar migrations (assumes createKeyspace was run before)
cleanMigrate
Recreates the keyspace (drops if exists && creates) and runs pillar migrations (useful for continuous integration scenarios)
createMigration
Create a new migration file from the name passed in.

e.g.

$ sbt 'createMigration create_user_settings'
[info] Loading config file: db/pillar.conf for environment: development
[info] Creating migration file: db/migrations/20160520105550_create_user_settings_timeseries.cql
[success] Created migration 'db/migrations/20160520105550_create_user_settings_timeseries.cql'
$ sbt cleanMigrate
[info] Loading config file: db/pillar.conf for environment: development
[info] Dropping keyspace pigeon at 192.168.42.45:9042
[info] Creating keyspace pigeon at 192.168.42.45:9042
[info] Migrating keyspace pigeon at 192.168.42.45:9042
[success] Total time: 10 s, completed 20-May-2016 11:07:05

Todo

Currently only the replication strategy 'SimpleStrategy' works. This will be resolved in next version.

License

The license is MIT (https://opensource.org/licenses/MIT), have at it!

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.