# GenerateMigrationsMojo

@Mojo(name = "generate-migrations", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true)
@Execute(phase = LifecyclePhase.COMPILE)
class GenerateMigrationsMojo : AbstractMojo

Mojo for generating SQL migration scripts from Exposed table definitions.

Goal: `exposed:generate-migrations`.

## Constructors

GenerateMigrationsMojo
Link copied to clipboard
constructor()

## Properties

databasePassword
Link copied to clipboard
@Parameter(property = "exposed.migrations.databasePassword")
var databasePassword: String?

Password for the database connection. Required when testContainersImageName is not set.

databaseUrl
Link copied to clipboard
@Parameter(property = "exposed.migrations.databaseUrl")
var databaseUrl: String?

JDBC URL for the live database treated as the current schema. Required when testContainersImageName is not set.

databaseUser
Link copied to clipboard
@Parameter(property = "exposed.migrations.databaseUser")
var databaseUser: String?

Username for the database connection. Required when testContainersImageName is not set.

debug
Link copied to clipboard
@Parameter(property = "exposed.migrations.debug", defaultValue = "false")
var debug: Boolean

Whether to enable debug logging.

fileDirectory
Link copied to clipboard
@Parameter(property = "exposed.migrations.fileDirectory", defaultValue = "${project.basedir}/src/main/resources/db/migration")
lateinit var fileDirectory: File

Directory where generated migration scripts will be stored. Defaults to `src/main/resources/db/migration` relative to the project root.

fileExtension
Link copied to clipboard
@Parameter(property = "exposed.migrations.fileExtension", defaultValue = ".sql")
var fileExtension: String

File extension for migration scripts. Defaults to `.sql`.

filePrefix
Link copied to clipboard
@Parameter(property = "exposed.migrations.filePrefix", defaultValue = "V")
var filePrefix: String

Prefix for migration script names. Defaults to `V`.

fileSeparator
Link copied to clipboard
@Parameter(property = "exposed.migrations.fileSeparator", defaultValue = "__")
var fileSeparator: String

Separator for migration script names. Defaults to `__`.

fileVersionFormat
Link copied to clipboard
@Parameter(property = "exposed.migrations.fileVersionFormat", defaultValue = "TIMESTAMP_ONLY")
var fileVersionFormat: VersionFormat

Version format for migration script names. Defaults to using the full current timestamp (with seconds) in the format YYYYMMDDHHMMSS.

fullFileName
Link copied to clipboard
@Parameter(property = "exposed.migrations.filename")
var fullFileName: String?

Override that writes all migration statements to a single file with the given name. Must include the file extension. When set, all other filename configuration is ignored.

log
Link copied to clipboard
open var log: Log?
pluginContext
Link copied to clipboard
open var pluginContext: Map<*, *>?
tablesPackage
Link copied to clipboard
@Parameter(property = "exposed.migrations.tablesPackage", required = true)
lateinit var tablesPackage: String

Package name where Exposed table definitions are located.

testContainersImageName
Link copied to clipboard
@Parameter(property = "exposed.migrations.testContainersImageName")
var testContainersImageName: String?

Docker image name. When set, a Testcontainer is started and existing scripts in fileDirectory are applied via Flyway before generating new ones. Mutually exclusive with the live-database connection parameters.

useUpperCaseDescription
Link copied to clipboard
@Parameter(property = "exposed.migrations.useUpperCaseDescription", defaultValue = "true")
var useUpperCaseDescription: Boolean

Whether the descriptive part of migration script names should be all upper-case. Defaults to `true`.

## Functions

execute
Link copied to clipboard
open override fun execute()