Skip to content
Gerald Quintana edited this page May 25, 2016 · 6 revisions

Beep beep runs scripts on SQL and NoSQL databases and track already ran/new scripts.

It can be used to:

  • Create tables/indices/collections and populate them with data
  • Prepare a database for unit testing with JUnit
  • Setup and configure database for production use

With the same tool, these scripts can be ran on:

  • SQL scripts on relational databases using JDBC driver
  • Sense scripts on Elasticsearch
  • CQL scripts on Cassandra
  • And so on...

Features

Done

  • Scan scripts on file system and class path using file glob patterns: folder/**/prefix*.ext
  • Supported data stores: SQL through JDBC, Elasticsearch through HTTP, REST API
  • Track ran scripts and don't re-execute them
  • Forbid script changes once successfully ran
  • Search and replace ${placeholder} in scripts to make script environment independent

To do

  • Supported data stores: Cassandra, MongoDB...
  • Use shared lock to avoid simultaneous and concurrent execution
  • Option to continue running scripts after an error
  • Add options on per script basis:
    • script can be skipped in case of error,
    • script can be reran in case of change,
    • script must be reran each time,
    • script must be executed only if tag is present/absent,
    • end of line marker for this script is different
  • SQL dialects for script store table creation, support main databases

Usage

Command line

Run all scripts in the script folder on Elasticsearch located on localhost and track their execution in the .beepbeep index.

$ bin/beepbeep.sh  -t elasticsearch -d http://localhost:9200 -s .beepbeep/script -f 'script/*.json'

START script/index_create.json
END_SUCCESS script/index_create.json:24
START script/index_data.json
END_SUCCESS script/index_data.json:15

Java API

Run all SQL scripts from the classpath on a H2 embedded database and replace ${variable} placeholders in scripts by value.

new SqlPipelineBuilder()
    .withConnectionProvider(Driver.class.getName(), "jdbc:h2:mem:test", "sa", "")
    .withVariable("variable", "value")
    .withResourcesScriptScanner(getClass().getClassLoader(),
      "com/github/gquintana/beepbeep/script/**/*.sql")
    .scan();

Installation

Build from source

  1. Install Java DK 8 and Apache Maven 3
  2. Run Maven mvn install

Command line tool

  1. Grab the target\beepbeep-x.y-bin.zip and unzip it anywhere
  2. If necessary, add your JDBC driver Jar in the lib folder
  3. If necessary, edit the configuration files in the config
Clone this wiki locally