i use the following changeset in liquibase to add a function to an existing database
<changeSet author="me" id="2">
<sqlFile encoding="UTF-8"
path="add_function_my_timestamp.sql"
relativeToChangelogFile="true"
splitStatements="false"
stripComments="false"
endDelimiter=";"/>
The content of the sql file (add_function_my_timestamp.sql) is
CREATE FUNCTION public.my_timestamp(some_time timestamp without time zone) RETURNS timestamp with time zone
LANGUAGE sql IMMUTABLE
AS $_$
select date_trunc('day', cast($1 AT TIME ZONE 'Europe/Berlin' as date))
$_$;
Liquibase tells me migration was successful
SQL in file add_function_my_timestamp.sql executed
ChangeSet update_20220223::2::me ran successfully in 13ms
But when i try to use the function created by this changeset in annother changeset when creating an index
<changeSet author="me" id="3">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*)
from information_schema.constraint_column_usage
where table_name = 'myEntity' and constraint_name = 'description_day_timestamp_unique'
</sqlCheck>
</preConditions>
<sql>
CREATE UNIQUE INDEX description_day_timestamp_unique ON myEntity."myProperty" USING btree (description, public.my_timestamp(insertdate));
</sql>
then i get the error
Reason: liquibase.exception.DatabaseException: ERROR: function
public.my_timestamp(timestamp with time zone) does not exist
Hint: No function matches the given name and argument types. You
might need to add explicit type casts.
I found error. Parameter type was wrong