Giter Club home page Giter Club logo

otter's Introduction

Otter

DB Migration Tool for Kotlin. Inspired by harmonica.

Specs

V1 Roadmap

  • New Syntax
  • Type Support
  • Alter
  • Sequence
  • Create user guide
  • Down
  • Target
  • SEEDING
  • Gradle Plugin - generate
  • Gradle Plugin - migrate
  • Gradle Plugin - rollback
  • Gradle Plugin - check

How-To

Spring

Add otter dependencies and task within your application.

// build.gradle.kts
/** ... */
dependencies {
    /** ... */
    implementation("io.github.goodgoodjm:otter-spring-boot-starter:0.0.23")
    implementation(kotlin("script-runtime")) // for migration files of resources
    /** ... */
}

// This task is needed to boot jar file
tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
    requiresUnpack("**/kotlin-compiler-embeddable-*.jar")
}
/** ... */

Add otter variables to your application's properties.

# application.yml
otter:
  driverClassName: ${spring.datasource.driver-class-name}
  url: ${spring.datasource.url}
  username: ${spring.datasource.username}
  password: ${spring.datasource.password}
  migrationPath: migrations
  showSql: true

Make your migration files at migrationPath.

// resources/migrations/M2022071016263342.kts

import io.github.goodgoodjm.otter.core.Migration
import io.github.goodgoodjm.otter.core.dsl.Constraint
import io.github.goodgoodjm.otter.core.dsl.and

object : Migration() {
    override fun up() {
        createTable("person") {
            "id" - INT constraints PRIMARY and AUTO_INCREMENT
            "name" - VARCHAR(30)
            "message" - VARCHAR
            "lat" - LONG constraints UNIQUE
            "nullable" - BOOL constraints NULLABLE
        }

        createTable("post") {
            "id" - INT constraints PRIMARY and AUTO_INCREMENT
            "person_id" - INT foreignKey "person(id)"
        }
    }

    override fun down() {
        dropTable("person")
        dropTable("post")
    }
}

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.