Skip to content

Commit

Permalink
api - change trigger target function type
Browse files Browse the repository at this point in the history
Target of trigger cannot be procedure, must be function that returns
type trigger.
  • Loading branch information
cherusk committed Nov 15, 2023
1 parent e01bb6a commit 9e0aaba
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions api/archive_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def create_trigger(trigger_name=None, table_name=None, procedure_name=None):
@staticmethod
def create_procedure(procedure_name=None, probability=1.0, source_table_name=None, target_table_name=None):
query = f"""
CREATE OR REPLACE PROCEDURE {procedure_name}()
LANGUAGE plpgsql
AS $body$
CREATE OR REPLACE FUNCTION {procedure_name}() RETURN TRIGGER AS $$
DECLARE
random_value real;
BEGIN
Expand All @@ -71,7 +69,7 @@ def create_procedure(procedure_name=None, probability=1.0, source_table_name=Non
END IF;
END;
$body$;
$$ LANGUAGE plpgsql;
"""

return query

0 comments on commit 9e0aaba

Please sign in to comment.