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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions migrations/tenant/0026-objects-prefixes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,28 @@ END;
$func$ LANGUAGE plpgsql VOLATILE;

-- "storage"."prefixes"
CREATE OR REPLACE TRIGGER "prefixes_delete_hierarchy"
DROP TRIGGER IF EXISTS "prefixes_delete_hierarchy" ON "storage"."prefixes";
CREATE 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"
DROP TRIGGER IF EXISTS "objects_insert_create_prefix" ON "storage"."objects";
CREATE 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"
DROP TRIGGER IF EXISTS "objects_update_create_prefix" ON "storage"."objects";
CREATE 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"
DROP TRIGGER IF EXISTS "objects_delete_delete_prefix" ON "storage"."objects";
CREATE TRIGGER "objects_delete_delete_prefix"
AFTER DELETE ON "storage"."objects"
FOR EACH ROW
EXECUTE FUNCTION "storage"."delete_prefix_hierarchy_trigger"();
Expand Down
3 changes: 2 additions & 1 deletion migrations/tenant/0035-add-insert-trigger-prefixes.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

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