Skip to content

Use drop trigger if exists to support pg12 #657

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jingsam
Copy link

@jingsam jingsam commented Apr 8, 2025

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

create or replace trigger only available up from PG14. When I connect to PG12, migration fails as

-- "storage"."prefixes"
CREATE OR REPLACE TRIGGER "prefixes_delete_hierarchy"
AFTER DELETE ON "storage"."prefixes"
FOR EACH ROW
EXECUTE FUNCTION "storage"."delete_prefix_hierarchy_trigger"();
-- "storage"."objects"
CREATE OR REPLACE TRIGGER "objects_insert_create_prefix"
BEFORE INSERT ON "storage"."objects"
FOR EACH ROW
EXECUTE FUNCTION "storage"."objects_insert_prefix_trigger"();
CREATE OR REPLACE TRIGGER "objects_update_create_prefix"
BEFORE UPDATE ON "storage"."objects"
FOR EACH ROW
WHEN (NEW.name != OLD.name)
EXECUTE FUNCTION "storage"."objects_insert_prefix_trigger"();
CREATE OR REPLACE TRIGGER "objects_delete_delete_prefix"
AFTER DELETE ON "storage"."objects"
FOR EACH ROW
EXECUTE FUNCTION "storage"."delete_prefix_hierarchy_trigger"();

-- This trigger is used to create the hierarchy of prefixes
-- When writing directly in the prefixes table
CREATE OR REPLACE TRIGGER "prefixes_create_hierarchy"
BEFORE INSERT ON "storage"."prefixes"
FOR EACH ROW
WHEN (pg_trigger_depth() < 1)
EXECUTE FUNCTION "storage"."prefixes_insert_trigger"();

contains unsupported syntax.

What is the new behavior?

Use drop trigger if exists / create trigger instead of create or replace trigger to support pg12.

Additional context

Add any other context or screenshots.

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

Successfully merging this pull request may close these issues.

1 participant