Init SQL
Published 31 October 2023
Init SQL
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.
Usage
Commandline
./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>