nhost
nhost copied to clipboard
PostgresQL functions/triggers are not synced to local after init --remote
Steps to reproduce:
- Create a new app on nhost dashboard.
- Open Hasura, then:
- Create a new table, for example,
profileswith 2 UUID columnsidanduser_id. - Add function, create a trigger, for example in my case, I made a sync trigger:
- Create a new table, for example,
CREATE OR REPLACE FUNCTION sync_user_profile() RETURNS TRIGGER AS
$BODY$
BEGIN
INSERT INTO
public.profiles(id, user_id)
VALUES(new.id, new.id);
RETURN new;
END;
$BODY$
language plpgsql;
CREATE TRIGGER trigger_sync
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE PROCEDURE sync_user_profile();
- Test by inserting a
userrow, it works fine as a newprofilerow was created. - Init the project locally with
nhost init --remoteand select the recently created app. - The app running on local will have a
profilestable, but theuserstable lost trigger.
Currently I have to work around by creating the function locally again. But the trigger can not be migrated as trigger does not have CREATE OR REPLACE.
This has been fixed in our CLI (https://github.com/nhost/cli/pull/324). Please upgrade the CLI (sudo nhost upgrade) and try again.