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 (defaults file) |
|
Global flow file argument (example) |
|
Global CLI parameter |
|
JVM system property (JAVA_OPTS Environment Variable) |
|
Liquibase Environment Variables |
|
For more information, see Working with Command Parameters.
Related links
- PostgreSQL: CREATE VIEW
--replace-if-exists-types
and--run-on-change-types
fordiff-changelog
andgenerate-changelog