Redgate Flyway

Environment Init SQL Setting

Description

SQL statements to be run immediately after a database connection has been established.

This is mainly used for setting some state on the connection that needs to be shared across all scripts, or should not be included into any one script.

This could effectively be considered an environment specific afterConnect callback.

Please note that this parameter defines an "Initial SQL command," not an "Initialization SQL command." It may be executed multiple times, as it runs immediately after each database connection is established.

Type

String

Default

none

Usage

Flyway Desktop

This can't be set in a config file via Flyway Desktop, although it will be honoured, and it can be configured as an advanced parameter in operations on the Migrations page.

Command-line

./flyway -initSql="ALTER SESSION SET NLS_LANGUAGE='ENGLISH';" info

To configure a named environment via command line when using a TOML configuration, prefix initSql with environments.{environment name}. for example:

./flyway "-environments.sample.initSql=ALTER SESSION SET NLS_LANGUAGE='ENGLISH';" info

TOML Configuration File

[environments.default]
initSql = "ALTER SESSION SET NLS_LANGUAGE='ENGLISH';"

Configuration File

flyway.initSql=ALTER SESSION SET NLS_LANGUAGE='ENGLISH';

Environment Variable

FLYWAY_INIT_SQL=ALTER SESSION SET NLS_LANGUAGE='ENGLISH';

API

Flyway.configure()
    .initSql("ALTER SESSION SET NLS_LANGUAGE='ENGLISH';")
    .load()

Gradle

flyway {
    initSql = "ALTER SESSION SET NLS_LANGUAGE='ENGLISH';"
}

Maven

<configuration>
    <initSql>ALTER SESSION SET NLS_LANGUAGE='ENGLISH';</initSql>
</configuration>

Didn't find what you were looking for?