From e74d0cdc60c1368cffdb55ce2139d42643e4617a Mon Sep 17 00:00:00 2001 From: Infendro Date: Thu, 2 Oct 2025 11:18:36 +0200 Subject: [PATCH] add README --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..38d1ca7 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Ktor Plugin for Database Migration + +This plugin enables code-based database migrations in Ktor using [Kotlin Database Migration](https://git.infendro.com/Infendro/kotlin-migration). + +## Installation + +Add the following to your `build.gradle.kts`. + +```kotlin +repositories { + maven("https://git.infendro.com/api/packages/Infendro/maven") +} + +dependencies { + implementation("com.infendro:ktor-migration:1.0.2") +} +``` + +## Usage + +```kotlin +import com.infendro.ktor.migration.Migration +import io.ktor.server.application.* +import org.jetbrains.exposed.sql.Database + +fun Application.configureDatabase() { + // connect to a database + Database.connect( + url = , + user = , + password = , + ) + + // install the plugin + install(Migration) { + // 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.