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
Create an enum type, with a table and a function that both use it
createtypeenum_type_1as enum ('val1', 'val2');
createtabletable_with_enum (
enum_col enum_type_1
);
createfunctionfunction_with_enum(param1 enum_type_1) returns void as $$
begin
raise notice '%', param1;
end;
$$ language plpgsql;
Add a value to the enum:
altertype enum_type_1 add value 'val3';
Generate a diff, which will result in:
altertype"public"."enum_type_1" rename to "enum_type_1__old_version_to_be_dropped";
createtype "public"."enum_type_1"as enum ('val1', 'val2', 'val3');
altertable"public"."table_with_enum" alter column enum_col type "public"."enum_type_1" using enum_col::text::"public"."enum_type_1";
droptype"public"."enum_type_1__old_version_to_be_dropped";
Expected
After the new enum is created with the extra val, the function that depends on it should be recreated with the new enum:
altertype"public"."enum_type_1" rename to "enum_type_1__old_version_to_be_dropped";
createtype "public"."enum_type_1"as enum ('val1', 'val2', 'val3');
altertable"public"."table_with_enum" alter column enum_col type "public"."enum_type_1" using enum_col::text::"public"."enum_type_1";
dropfunction function_with_enum(param1 enum_type_1__old_version_to_be_dropped);
createfunctionfunction_with_enum(param1 enum_type_1) returns void as $$
begin
raise notice '%', param1;
end;
$$ language plpgsql;
droptype"public"."enum_type_1__old_version_to_be_dropped";
Actual
altertype"public"."enum_type_1" rename to "enum_type_1__old_version_to_be_dropped";
createtype "public"."enum_type_1"as enum ('val1', 'val2', 'val3');
altertable"public"."table_with_enum" alter column enum_col type "public"."enum_type_1" using enum_col::text::"public"."enum_type_1";
droptype"public"."enum_type_1__old_version_to_be_dropped";
The function is not re-created with the new enum, so trying to run the diff results in this error: ERROR: cannot drop type enum_type_1__old_version_to_be_dropped because other objects depend on it (SQLSTATE 2BP01) At statement 3: drop type "public"."enum_type_1__old_version_to_be_dropped"
The text was updated successfully, but these errors were encountered:
Steps to reproduce:
Expected
After the new enum is created with the extra val, the function that depends on it should be recreated with the new enum:
Actual
The function is not re-created with the new enum, so trying to run the diff results in this error:
ERROR: cannot drop type enum_type_1__old_version_to_be_dropped because other objects depend on it (SQLSTATE 2BP01) At statement 3: drop type "public"."enum_type_1__old_version_to_be_dropped"
The text was updated successfully, but these errors were encountered: