Files
migration.kt/README.md
2025-10-03 11:43:16 +02:00

44 lines
933 B
Markdown

# Kotlin Database Migration
This library enables code-based database migrations in Kotlin.
## Features
* Declare database migrations (identified by a unique name).
* Migrations are executed in the order they are declared in.
* Executed migrations are tracked in a database table and skipped on subsequent runs.
## Installation
Add the following to your `build.gradle.kts`.
```kotlin
repositories {
maven("https://git.infendro.com/api/packages/Infendro/maven")
}
dependencies {
implementation("com.infendro:migration:1.1.0")
}
```
## Usage
```kotlin
import com.infendro.migration.migrate
import org.jetbrains.exposed.sql.Database
fun configureDatabase() {
// connect to a database
Database.connect(/* parameters */)
// declare and execute migrations
migrate {
// create a migration
migration("initial") {
// execute code to migrate the database
}
}
}
```