always-drop-instead-of-replace

--always-drop-instead-of-replace is a Boolean global parameter. If set to true, Liquibase always drops and recreates a view instead of replacing it. The parameter only affects PostgreSQL databases. The default value is false.

Uses

You can create a view in your database with the createView Change Type. If you set the replaceIfExists attribute to true in your changeset, Liquibase uses the SQL statement CREATE OR REPLACE VIEW to create the view when you run a command like update. This means that if there is already a view of that name, Liquibase replaces the existing view instead of returning an error.

However, the PostgreSQL implementation of CREATE OR REPLACE VIEW has restrictions on column ordering and data types. If you try to create a new view with the same name as an existing view, but with a different structure, PostgreSQL returns an error. The --always-drop-instead-of-replace parameter lets you avoid this error by dropping the existing view and then recreating it.

If you enable --always-drop-instead-of-replace on a non-PostgreSQL database, it has no effect.

Syntax

You can set this parameter in the following ways:

Option Syntax
Liquibase properties file
liquibase.alwaysDropInsteadOfReplace: <true|false>
Global flow file argument (example)
stages:
  Default:
    actions:
      - type: liquibase
        command: update
        globalArgs: { always-drop-instead-of-replace: "<true|false>" }
Global CLI parameter
liquibase
 --always-drop-instead-of-replace=<true|false> update
 --changelog-file=example-changelog.xml

JVM system property (JAVA_OPTS Environment Variable)

JAVA_OPTS=-Dliquibase.alwaysDropInsteadOfReplace=<true|false>
Liquibase Environment Variables
LIQUIBASE_ALWAYS_DROP_INSTEAD_OF_REPLACE=<true|false>

For more information, see Working with Command Parameters.

Related links