Skip to content

Repository files navigation

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.ymlotter:
driverClassName: ${spring.datasource.driver-class-name}url: ${spring.datasource.url}username: ${spring.datasource.username}password: ${spring.datasource.password}migrationPath: migrationsshowSql: true

Make your migration files at migrationPath.

// resources/migrations/M2022071016263342.ktsimportio.github.goodgoodjm.otter.core.Migrationimportio.github.goodgoodjm.otter.core.dsl.Constraintimportio.github.goodgoodjm.otter.core.dsl.andobject:Migration() {
overridefunup() {
createTable("person") {
"id"-INT constraints PRIMARYandAUTO_INCREMENT"name"-VARCHAR(30)
"message"-VARCHAR"lat"-LONG constraints UNIQUE"nullable"-BOOL constraints NULLABLE
}
createTable("post") {
"id"-INT constraints PRIMARYandAUTO_INCREMENT"person_id"-INT foreignKey "person(id)"
}
}
overridefundown() {
dropTable("person")
dropTable("post")
}
}

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages