Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@brianeyoung
Copy link

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.
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[]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant