always-override-stored-logic-schema

The always-override-stored-logic-schema global parameter is a Boolean value that you can use with the createProcedure Change Type.

When you generate SQL for a procedure without specifying a schema name, always-override-stored-logic-schema decides whether to explicitly include the default schema name with your procedure in the SQL.

The default value of always-override-stored-logic-schema is false.

schemaName attribute

You can use the createProcedure Change Type to define a stored SQL procedure in your changelog or a file you specify. createProcedure has an optional attribute called schemaName that determines which schema the procedure is created in.

When you create a procedure in Liquibase, the outputs of the update-sql command and rollback-sql command change based on what you specify for schemaName and always-override-stored-logic-schema:

  • If you do specify schemaName, Liquibase explicitly prefixes your schema name to your procedure name in the CREATE PROCEDURE statement of the SQL. Liquibase does this even if the schema name was not specified in the actual SQL, and no matter what you set always-override-stored-logic-schema to:

    CREATE <your_schema>.<your_procedure> AS…
  • If you don't specify schemaName and you set always-override-stored-logic-schema to true, Liquibase prefixes the value of the default-schema-name parameter to your procedure name:

    CREATE <default_schema>.<your_procedure> AS…
  • If you don't specify schemaName and you set always-override-stored-logic-schema to false, Liquibase does not explicitly modify the SQL to include the schema name. However, Liquibase still creates your procedure in schema specified by default-schema-name:

    CREATE <your_procedure> AS…

Note: You can set a value for default-schema-name or use the default one, which depends on your database. For example, the default value on an H2 database is PUBLIC.

Uses

If you run the SQL generated with update-sql or rollback-sql on another database or client, the new system may have a different setting of default-schema-name than the old one. In this case, you can set always-override-stored-logic-schema to true to ensure that objects are consistently created in the same schema names across multiple databases.

The always-override-stored-logic-schema parameter also affects the SQL Liquibase uses with the update command and rollback command. However, when you use these two commands, Liquibase always creates objects in the same schemas, even if the default schemas are different across the two systems, and regardless of the value of always-override-stored-logic-schema.

Note: Some databases store SQL in an alias instead of a procedure, such as H2. In these cases, Liquibase may not explicitly add the schema prefix to the alias in the update-sql output. However, Liquibase

Syntax

For more information, see Working with Command Parameters. You can set this parameter in the following ways:

Option Syntax
Liquibase properties file
liquibase.alwaysOverrideStoredLogicSchema: <true|false>
Global CLI parameter
liquibase
 --always-override-stored-logic-schema=<true|false> update
 --changelog-file=mychangelog.xml

JVM system property

JAVA_OPTS Environment Variable

macOS/Linux:
JAVA_OPTS=-Dliquibase.alwaysOverrideStoredLogicSchema=<true|false>
Windows:
set JAVA_OPTS=-Dliquibase.alwaysOverrideStoredLogicSchema=<true|false>
Liquibase Environment Variables macOS/Linux:
LIQUIBASE_ALWAYS_OVERRIDE_STORED_LOGIC_SCHEMA=<true|false>
Windows:
set LIQUIBASE_ALWAYS_OVERRIDE_STORED_LOGIC_SCHEMA=<true|false>

Note: These commands only apply to the current shell. To set permanent environment variables, see Liquibase Environment Variables.