GithubHelp home page GithubHelp logo

dbmigrator-example's Introduction

dbmigrator

Utility for managing database migration scripts and versioning.

Project Structure

Migrations are stored in the following directories (please refer to the links below for more information):

Development

Common tasks for developing and testing migrations locally are detailed below:

Adding New Script Migration

Run the following command to create a new script migration:

./gradlew createMigrationScript --type="{migration type}" --ver="{version}" --desc="{description}"

Example:

./gradlew createMigrationScript --type="V" --ver="1.0.21" --desc="Add Table Foo"

The newly created script can be found in the script migration directory (src/main/resources/db/migration).

If you wish to create an environment-specific migration script, simply include the optional --env parameter:

./gradlew createMigrationScript --type="{migration type}" --ver="{version}" --desc="{description}" --env="{environment}"

Example:

./gradlew createMigrationScript --type="V" --ver="1.0.21" --desc="Add Table Foo" --env="test"

The newly created script can be found in the test script migration directory (src/main/resources/db/migration-env/test).

Adding New Java Migration

Run the following command to create a new Java migration:

./gradlew createMigrationClass --type="{migration type}" --ver="{version}" --desc="{description}"

Example:

./gradlew createMigrationClass --type="V" --ver="1.0.21" --desc="Add Table Foo"

The newly created class can be found in the java migration package (src/main/java/db/migration).

Building

Run the following command to build the application:

./gradlew clean build

Run the following command to build the application as a Docker image (Executable Jar):

./gradlew clean buildImage

Run the following command to build the application as a Docker image (Spring Boot):

./gradlew clean buildBootImage

Running Migrations Locally

The project is configured to use Docker Compose for testing migrations locally and there are a number of Gradle tasks provided to make the task easy.

Migrate Database

Run the following command to execute the database migration:

./gradlew migrateDb

Delete Database

Run the following command to delete the database:

./gradlew cleanDb

Delete Database and Run Migration

Run the following command to delete the database and rerun the migration:

./gradlew cleanMigrateDb

Delete Database and Mounted Data Volumes

The MySQL container makes use of volumes to store data across container invocations. Run the following command to delete the database, the associated data volumes, and start with a fresh instance:

./gradlew killDb

Integration Testing

The project contains a set of integration tests for validating the database schema post migration. Run the following command to execute the integration tasks locally:

./gradlew clean build integrationTest

For more information on adding integration tests, please refer to the Integration Test Documentation.

dbmigrator-example's People

Contributors

gregwhitaker avatar

Stargazers

 avatar

Watchers

 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.