cli icon indicating copy to clipboard operation
cli copied to clipboard

`--use-migra` command does not pick up a DB trigger that was created

Open rcwestlake opened this issue 2 years ago • 0 comments

Describe the bug The npx supabase db diff --use-migra command is not picking a new db trigger that was created using the SQL editor locally. It did pick up the function that was created.

To Reproduce Steps to reproduce the behavior:

  1. Run the CLI locally
  2. In the local host studio dashboard, run this in the SQL editor:
create function public.create_profile()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
  insert into public.profiles (user_id)
  values (new.id);
  return new;
end;
$$;

create trigger create_profile_after_auth_user_insert
after insert on auth.users
for each row
execute procedure public.create_profile();
  1. You can verify that both the function and trigger are created in the studio dashboard
  2. Run the npx supabase db diff --use-migra command. This will create a new migration file.
  3. The migration file includes the command to create the function but not the trigger.
CREATE OR REPLACE FUNCTION public.create_profile()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
 SET search_path TO 'public'
AS $function$
begin
  insert into public.profiles (user_id)
  values (new.id);
  return new;
end;
$function$
;

Expected behavior The migration command should pick up the trigger that was created.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ventura 13.2.1
  • Browser (if applicable) [e.g. chrome, safari]
  • Version of CLI 1.99.5
  • Version of supabase-js (if applicable) ^2.36.0
  • Version of Node.js (if applicable) v20.5.1

Additional context Add any other context about the problem here.

rcwestlake avatar Sep 21 '23 22:09 rcwestlake