gh0st
gh0st

Reputation: 1722

liquibase throws illegal argument exception on key 'create'

Using liquibase:4.27.0 with the following changelog/changeset throws the following error...

liquibase.properties

changeLogFile: changelog/changeset.yml
url: jdbc:postgresql://my-postgres-server:5432/my-db
driver: org.postgresql.Driver
classpath: /liquibase/internal/lib/postgresql.jar
defaultSchemaName: my_schema

changelog/changeset.yml

databaseChangeLog:
  - changeSet:
      id: initial-views
      author: Banana Man
      runOnChange: true
      changes:
        - createView:
          schema_name: my_schema
          path: path/to/my/view.sql
          viewName: my_view
          fullDefinition: true
          replaceIfExists: true

view.sql

select *
from banana
limit 100;

I guess lastly I should add that I'm running this from a liquibase container

docker run -it -v /file-location:/on-container liquibase bash

The error I get form a liquibase update-sql is as follows

$liquibase update-sql

...
SET SEARCH_PATH TO my_schema, "$user","public";

ERROR: Exception Details
ERROR: Exception Primary Class: IllegalArgumentException
ERROR: Exception Primary Reason: Key 'create' is not defined
ERROR: Exception Primary Source: PostgreSQL 15.7

Unexpected error running Liquibase: Migration failed for changeset mychangelog.yml::initial-views::Banana Man:
    Reason: java.lang.IllegalArguementException: Key 'create' is not defined
...

What am I doing wrong?

Upvotes: 0

Views: 48

Answers (2)

barix
barix

Reputation: 1

You need to include fullDefinition: true, when the view.sql is the entire view definition, like this:

create view my_view as
select *
from banana
limit 100;

In your case the header create view should be added by liquibase, hence fullDefinition: false (see Liquibase createView doc).

Upvotes: 0

gh0st
gh0st

Reputation: 1722

You do not need to include fullDefinition: true in the changeset's changes.

Upvotes: 0

Related Questions