Compare commits
6 Commits
27b335a0af
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
4636768184
|
|||
|
d26f0a1310
|
|||
|
e3931e3e8f
|
|||
|
3380f50cc7
|
|||
|
b777eadd13
|
|||
|
bba1f2d63d
|
@@ -1,34 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
INFENDRO__TOKEN: ${{ secrets.TOKEN }}
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache/restore@v4
|
||||
with:
|
||||
key: gradle
|
||||
path: |
|
||||
~/.gradle/caches/
|
||||
~/.gradle/wrapper/
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '24'
|
||||
distribution: 'temurin'
|
||||
|
||||
- run: ./gradlew publish
|
||||
|
||||
- uses: actions/cache/save@v4
|
||||
with:
|
||||
key: gradle
|
||||
path: |
|
||||
~/.gradle/caches/
|
||||
~/.gradle/wrapper/
|
||||
30
.gitea/workflows/publish.yaml
Normal file
30
.gitea/workflows/publish.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: linux
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '24'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Cache Gradle
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
||||
restore-keys: gradle
|
||||
path: |
|
||||
~/.gradle/caches/
|
||||
~/.gradle/wrapper/
|
||||
|
||||
- name: Publish
|
||||
run: ./gradlew publish
|
||||
env:
|
||||
INFENDRO__TOKEN: ${{ secrets.TOKEN }}
|
||||
16
README.md
16
README.md
@@ -1,12 +1,6 @@
|
||||
# Ktor Plugin for Database Migration
|
||||
# migration-ktor
|
||||
|
||||
This plugin enables code-based database migrations in Ktor using [Kotlin Database Migration](https://git.infendro.com/Infendro/kotlin-migration).
|
||||
|
||||
## 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.
|
||||
`migration-ktor` is a Kotlin library that enables code-based migrations in Ktor.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -18,17 +12,13 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.infendro:ktor-migration:1.1.0")
|
||||
implementation("com.infendro:ktor-migration:1.2.0")
|
||||
}
|
||||
```
|
||||
|
||||
## 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(/* parameters */)
|
||||
|
||||
@@ -2,7 +2,7 @@ import com.infendro.plugin.infendro
|
||||
import com.infendro.plugin.token
|
||||
|
||||
group = "com.infendro"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.infendro)
|
||||
@@ -16,9 +16,10 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.migration)
|
||||
implementation(libs.ktor.server)
|
||||
implementation(libs.migration)
|
||||
implementation(libs.exposed)
|
||||
implementation(libs.exposed.jdbc)
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
[versions]
|
||||
infendro = "1.0.0"
|
||||
kotlin = "2.2.10"
|
||||
ktor = "3.2.3"
|
||||
exposed = "0.61.0"
|
||||
migration = "1.1.1"
|
||||
infendro = "1.1.0"
|
||||
kotlin = "2.3.0"
|
||||
ktor = "3.4.0"
|
||||
migration = "1.2.0"
|
||||
exposed = "1.0.0"
|
||||
|
||||
[plugins]
|
||||
infendro = { id = "com.infendro.plugin", version.ref = "infendro" }
|
||||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
|
||||
[libraries]
|
||||
migration = { module = "com.infendro:migration", version.ref = "migration" }
|
||||
ktor-server = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
|
||||
migration = { module = "com.infendro:migration", version.ref = "migration" }
|
||||
exposed = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }
|
||||
exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" }
|
||||
|
||||
@@ -2,20 +2,18 @@ package com.infendro.ktor.migration
|
||||
|
||||
import com.infendro.migration.migrate
|
||||
import io.ktor.server.application.*
|
||||
import org.jetbrains.exposed.sql.Transaction
|
||||
import org.jetbrains.exposed.v1.jdbc.JdbcTransaction
|
||||
|
||||
val Migration = createApplicationPlugin(
|
||||
name = "Migration",
|
||||
createConfiguration = { MigrationConfig() },
|
||||
) {
|
||||
val Migration = createApplicationPlugin("Migration", MigrationConfig::new) {
|
||||
migrate(pluginConfig.config)
|
||||
}
|
||||
|
||||
class MigrationConfig {
|
||||
internal val config = com.infendro.migration.MigrationConfig()
|
||||
|
||||
fun migration(
|
||||
name: String,
|
||||
migrate: Transaction.() -> Unit,
|
||||
) = config.migration(name, migrate)
|
||||
fun migration(name: String, migrate: JdbcTransaction.() -> Unit) = config.migration(name, migrate)
|
||||
|
||||
companion object {
|
||||
fun new() = MigrationConfig()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user