You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drop statement not generated for function which return a PostgreSql TABLE when the only change to the function is columns being added to or removed from the returned TABLE
#227
Open
brianeyoung opened this issue
Apr 13, 2023
· 0 comments
Drop statements are not generated for functions which return a PostgreSql TABLE when the only change to the function is columns being added to or removed from the returned TABLE. Error then occurs when CREATE OR REPLACE FUNCTION statement generated by Migra is executed.
E.g.
SQL State : 42P13
Error Code : 0
Message : ERROR: cannot change return type of existing function
Detail: Row type defined by OUT parameters is different.
Hint: Use DROP FUNCTION organisation.gcidr_authorisationperiod(timestamp with time zone,timestamp with time zone,integer[]) first.
Location : db/migration/V1.2__changed_RegionCalendar_and_SettingCalendar_to_entity_tables.sql (/home/earlyyears-data-organisation-repo/organisation/target/classes/db/migration/V1.2__changed_RegionCalendar_and_SettingCalendar_to_entity_tables.sql)
Line : 2883
Statement : CREATE OR REPLACE FUNCTION organisation.gcidr_authorisationperiod(_fromtimestamp timestamp with time zone, _totimestamp timestamp with time zone, _operationtypes integer[])
RETURNS TABLE(authorisationperiod_id integer, authorisationperiod_uuid uuid, region_id integer, date_of_birth_from date, date_of_birth_to date, name character varying, end_date date, start_date date, changed_timestamp timestamp with time zone, version integer, crud_operation_id smallint, changed_user_id integer)
LANGUAGE plpgsql
SECURITY DEFINER
AS $function$
BEGIN …
There is no problem if a column changes, e.g. becomes nullable, as the CREATE OR REPLACE FUNCTION statement executes without error.
There is no problem if input parameters are added or removed to the function as Migra generates drops statements.
E.g. drop function if exists "organisation"."gcidr_authorisationperiod"(_fromtimestamp timestamp with time zone, _totimestamp timestamp with time zone, _operationtypes integer[]);
The text was updated successfully, but these errors were encountered:
Possibly a duplicate or related to #174.
Drop statements are not generated for functions which return a PostgreSql TABLE when the only change to the function is columns being added to or removed from the returned TABLE. Error then occurs when CREATE OR REPLACE FUNCTION statement generated by Migra is executed.
E.g.$function$
SQL State : 42P13
Error Code : 0
Message : ERROR: cannot change return type of existing function
Detail: Row type defined by OUT parameters is different.
Hint: Use DROP FUNCTION organisation.gcidr_authorisationperiod(timestamp with time zone,timestamp with time zone,integer[]) first.
Location : db/migration/V1.2__changed_RegionCalendar_and_SettingCalendar_to_entity_tables.sql (/home/earlyyears-data-organisation-repo/organisation/target/classes/db/migration/V1.2__changed_RegionCalendar_and_SettingCalendar_to_entity_tables.sql)
Line : 2883
Statement : CREATE OR REPLACE FUNCTION organisation.gcidr_authorisationperiod(_fromtimestamp timestamp with time zone, _totimestamp timestamp with time zone, _operationtypes integer[])
RETURNS TABLE(authorisationperiod_id integer, authorisationperiod_uuid uuid, region_id integer, date_of_birth_from date, date_of_birth_to date, name character varying, end_date date, start_date date, changed_timestamp timestamp with time zone, version integer, crud_operation_id smallint, changed_user_id integer)
LANGUAGE plpgsql
SECURITY DEFINER
AS
BEGIN …
There is no problem if a column changes, e.g. becomes nullable, as the CREATE OR REPLACE FUNCTION statement executes without error.
There is no problem if input parameters are added or removed to the function as Migra generates drops statements.
E.g.
drop function if exists "organisation"."gcidr_authorisationperiod"(_fromtimestamp timestamp with time zone, _totimestamp timestamp with time zone, _operationtypes integer[]);
The text was updated successfully, but these errors were encountered: