44
README.md
Normal file
44
README.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Kotlin Database Migration
|
||||||
|
|
||||||
|
This library enables code-based database migrations in Kotlin.
|
||||||
|
|
||||||
|
## 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.0.0")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun configureDatabase() {
|
||||||
|
// connect to a database
|
||||||
|
Database.connect(
|
||||||
|
url = <url>,
|
||||||
|
user = <username>,
|
||||||
|
password = <password>,
|
||||||
|
)
|
||||||
|
|
||||||
|
// declare and execute migrations
|
||||||
|
migrate {
|
||||||
|
// create a migration
|
||||||
|
migration("initial") {
|
||||||
|
// execute code to migrate the database
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
|
* Each migration is 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.
|
||||||
Reference in New Issue
Block a user