All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.koalaql.mysql.MysqlDataSource.kt Maven / Gradle / Ivy

There is a newer version: 0.0.14
Show newest version
package io.koalaql.mysql

import io.koalaql.DeclareStrategy
import io.koalaql.JdbcSchemaDetection
import io.koalaql.ddl.Table
import io.koalaql.ddl.diff.SchemaChange
import io.koalaql.event.DataSourceEvent
import io.koalaql.jdbc.JdbcDataSource
import io.koalaql.jdbc.JdbcProvider
import java.sql.DatabaseMetaData

fun MysqlDataSource(
    provider: JdbcProvider,
    declareBy: DeclareStrategy = DeclareStrategy.EXPECT,
    events: DataSourceEvent = DataSourceEvent.DISCARD
): JdbcDataSource = JdbcDataSource(
    object : JdbcSchemaDetection {
        override fun detectChanges(dbName: String, metadata: DatabaseMetaData, tables: List): SchemaChange =
            MysqlSchemaDiff(dbName, metadata).detectChanges(tables)
    },
    MysqlDialect(),
    provider,
    MysqlTypeMappings(),
    declareBy,
    events
)