From 85a8a99f2fff65aa0c14901de06734331ac66bd3 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Thu, 22 Feb 2024 22:10:10 -0600 Subject: [PATCH] Schema-qualify * Schema-qualifies everything. * Removes `search_path` assignments. * Moves all functions to the `artwork_indexer` schema. This is more convenient than having them in separate schemas. --- generate_code.py | 35 ++++++++++++++++------------------- sql/caa_functions.sql | 24 +++++++++++------------- sql/caa_triggers.sql | 23 +++++++++++------------ sql/create_schema.sql | 36 +++++++++++++++++------------------- sql/eaa_functions.sql | 16 +++++++--------- sql/eaa_triggers.sql | 15 +++++++-------- 6 files changed, 69 insertions(+), 80 deletions(-) diff --git a/generate_code.py b/generate_code.py index b2df1c4..9cac592 100644 --- a/generate_code.py +++ b/generate_code.py @@ -66,7 +66,7 @@ q_im_table = f'{im_schema}.{im_table}' for tg_op in im['tg_ops']: - extra_functions_source += f'\nCREATE OR REPLACE FUNCTION artwork_indexer_a_{tg_op}_{im_table}() RETURNS trigger AS $$\n' + extra_functions_source += f'\nCREATE OR REPLACE FUNCTION artwork_indexer.a_{tg_op}_{im_table}() RETURNS trigger AS $$\n' extra_functions_source += 'BEGIN\n' tg_rowvar = 'OLD' if tg_op == 'del' else 'NEW' @@ -128,15 +128,15 @@ extra_functions_source += 'END;\n' extra_functions_source += '$$ LANGUAGE plpgsql;\n' - tg_fn_name = f'artwork_indexer_a_{tg_op}_{im_table}' - tg_name = f'{tg_fn_name}' + tg_fn_name = f'a_{tg_op}_{im_table}' + tg_name = f'artwork_indexer_{tg_fn_name}' extra_triggers_source += dedent(f''' DROP TRIGGER IF EXISTS {tg_name} ON {q_im_table}; CREATE TRIGGER {tg_name} AFTER {TG_OP_FULLNAMES[tg_op]} ON {q_im_table} FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.{tg_fn_name}(); + EXECUTE PROCEDURE artwork_indexer.{tg_fn_name}(); ''') def index_artwork_stmt(gids, parent): @@ -179,9 +179,7 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): functions_source = dedent(f'''\ -- Automatically generated, do not edit. - SET LOCAL search_path = {art_schema}; - - CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_{art_table}() RETURNS trigger AS $$ + CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_{art_table}() RETURNS trigger AS $$ DECLARE {entity_type}_gid UUID; BEGIN @@ -196,7 +194,7 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): END; $$ LANGUAGE plpgsql; - CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_{art_table}() RETURNS trigger AS $$ + CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_{art_table}() RETURNS trigger AS $$ DECLARE suffix TEXT; old_{entity_type}_gid UUID; @@ -243,7 +241,7 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): END; $$ LANGUAGE plpgsql; - CREATE OR REPLACE FUNCTION artwork_indexer_a_del_{art_table}() + CREATE OR REPLACE FUNCTION artwork_indexer.a_del_{art_table}() RETURNS trigger AS $$ DECLARE suffix TEXT; @@ -263,7 +261,7 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): END; $$ LANGUAGE plpgsql; - CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_{art_table}_type() RETURNS trigger AS $$ + CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_{art_table}_type() RETURNS trigger AS $$ DECLARE {entity_type}_gid UUID; BEGIN @@ -279,7 +277,7 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): END; $$ LANGUAGE plpgsql; - CREATE OR REPLACE FUNCTION artwork_indexer_a_del_{art_table}_type() RETURNS trigger AS $$ + CREATE OR REPLACE FUNCTION artwork_indexer.a_del_{art_table}_type() RETURNS trigger AS $$ DECLARE {entity_type}_gid UUID; BEGIN @@ -299,7 +297,7 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): END; $$ LANGUAGE plpgsql; - CREATE OR REPLACE FUNCTION artwork_indexer_a_del_{entity_table}() RETURNS trigger AS $$ + CREATE OR REPLACE FUNCTION artwork_indexer.a_del_{entity_table}() RETURNS trigger AS $$ BEGIN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) VALUES ('{entity_type}', 'deindex', jsonb_build_object('gid', OLD.gid)) @@ -327,7 +325,6 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): triggers_source = dedent(f'''\ -- Automatically generated, do not edit. - SET LOCAL search_path = '{art_schema}'; SET LOCAL client_min_messages = warning; -- We drop the triggers first to simulate "CREATE OR REPLACE," @@ -337,37 +334,37 @@ def delete_artwork_stmt(artwork_id, gid, suffix, parent, return_var): CREATE TRIGGER artwork_indexer_a_ins_{art_table} AFTER INSERT ON {art_schema}.{art_table} FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.artwork_indexer_a_ins_{art_table}(); + EXECUTE PROCEDURE artwork_indexer.a_ins_{art_table}(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_{art_table} ON {art_schema}.{art_table}; CREATE TRIGGER artwork_indexer_a_upd_{art_table} AFTER UPDATE ON {art_schema}.{art_table} FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.artwork_indexer_a_upd_{art_table}(); + EXECUTE PROCEDURE artwork_indexer.a_upd_{art_table}(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_{art_table} ON {art_schema}.{art_table}; CREATE TRIGGER artwork_indexer_a_del_{art_table} AFTER DELETE ON {art_schema}.{art_table} FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.artwork_indexer_a_del_{art_table}(); + EXECUTE PROCEDURE artwork_indexer.a_del_{art_table}(); DROP TRIGGER IF EXISTS artwork_indexer_a_ins_{art_table}_type ON {art_schema}.{art_table}_type; CREATE TRIGGER artwork_indexer_a_ins_{art_table}_type AFTER INSERT ON {art_schema}.{art_table}_type FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.artwork_indexer_a_ins_{art_table}_type(); + EXECUTE PROCEDURE artwork_indexer.a_ins_{art_table}_type(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_{art_table}_type ON {art_schema}.{art_table}_type; CREATE TRIGGER artwork_indexer_a_del_{art_table}_type AFTER DELETE ON {art_schema}.{art_table}_type FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.artwork_indexer_a_del_{art_table}_type(); + EXECUTE PROCEDURE artwork_indexer.a_del_{art_table}_type(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_{entity_table} ON {entity_schema}.{entity_table}; CREATE TRIGGER artwork_indexer_a_del_{entity_table} AFTER DELETE ON {entity_schema}.{entity_table} FOR EACH ROW - EXECUTE PROCEDURE {art_schema}.artwork_indexer_a_del_{entity_table}(); + EXECUTE PROCEDURE artwork_indexer.a_del_{entity_table}(); ''') triggers_source += extra_triggers_source + '\n' diff --git a/sql/caa_functions.sql b/sql/caa_functions.sql index 7d70137..fe55ecb 100644 --- a/sql/caa_functions.sql +++ b/sql/caa_functions.sql @@ -1,8 +1,6 @@ -- Automatically generated, do not edit. -SET LOCAL search_path = cover_art_archive; - -CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_cover_art() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_cover_art() RETURNS trigger AS $$ DECLARE release_gid UUID; BEGIN @@ -17,7 +15,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_cover_art() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_cover_art() RETURNS trigger AS $$ DECLARE suffix TEXT; old_release_gid UUID; @@ -64,7 +62,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_cover_art() +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_cover_art() RETURNS trigger AS $$ DECLARE suffix TEXT; @@ -84,7 +82,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_cover_art_type() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_cover_art_type() RETURNS trigger AS $$ DECLARE release_gid UUID; BEGIN @@ -100,7 +98,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_cover_art_type() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_cover_art_type() RETURNS trigger AS $$ DECLARE release_gid UUID; BEGIN @@ -120,7 +118,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_release() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_release() RETURNS trigger AS $$ BEGIN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) VALUES ('release', 'deindex', jsonb_build_object('gid', OLD.gid)) @@ -138,7 +136,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_artist() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_artist() RETURNS trigger AS $$ BEGIN IF (OLD.name != NEW.name OR OLD.sort_name != NEW.sort_name) THEN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) ( @@ -158,7 +156,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_release() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_release() RETURNS trigger AS $$ BEGIN IF (OLD.name != NEW.name OR OLD.artist_credit != NEW.artist_credit OR OLD.language IS DISTINCT FROM NEW.language OR OLD.barcode IS DISTINCT FROM NEW.barcode) THEN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) ( @@ -177,7 +175,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_release_meta() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_release_meta() RETURNS trigger AS $$ BEGIN IF (OLD.amazon_asin IS DISTINCT FROM NEW.amazon_asin) THEN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) ( @@ -196,7 +194,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_release_first_release_date() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_release_first_release_date() RETURNS trigger AS $$ BEGIN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) ( SELECT 'release', 'index', jsonb_build_object('gid', musicbrainz.release.gid) @@ -213,7 +211,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_release_first_release_date() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_release_first_release_date() RETURNS trigger AS $$ BEGIN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) ( SELECT 'release', 'index', jsonb_build_object('gid', musicbrainz.release.gid) diff --git a/sql/caa_triggers.sql b/sql/caa_triggers.sql index 08f3607..97574eb 100644 --- a/sql/caa_triggers.sql +++ b/sql/caa_triggers.sql @@ -1,6 +1,5 @@ -- Automatically generated, do not edit. -SET LOCAL search_path = 'cover_art_archive'; SET LOCAL client_min_messages = warning; -- We drop the triggers first to simulate "CREATE OR REPLACE," @@ -10,65 +9,65 @@ DROP TRIGGER IF EXISTS artwork_indexer_a_ins_cover_art ON cover_art_archive.cove CREATE TRIGGER artwork_indexer_a_ins_cover_art AFTER INSERT ON cover_art_archive.cover_art FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_ins_cover_art(); + EXECUTE PROCEDURE artwork_indexer.a_ins_cover_art(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_cover_art ON cover_art_archive.cover_art; CREATE TRIGGER artwork_indexer_a_upd_cover_art AFTER UPDATE ON cover_art_archive.cover_art FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_upd_cover_art(); + EXECUTE PROCEDURE artwork_indexer.a_upd_cover_art(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_cover_art ON cover_art_archive.cover_art; CREATE TRIGGER artwork_indexer_a_del_cover_art AFTER DELETE ON cover_art_archive.cover_art FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_del_cover_art(); + EXECUTE PROCEDURE artwork_indexer.a_del_cover_art(); DROP TRIGGER IF EXISTS artwork_indexer_a_ins_cover_art_type ON cover_art_archive.cover_art_type; CREATE TRIGGER artwork_indexer_a_ins_cover_art_type AFTER INSERT ON cover_art_archive.cover_art_type FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_ins_cover_art_type(); + EXECUTE PROCEDURE artwork_indexer.a_ins_cover_art_type(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_cover_art_type ON cover_art_archive.cover_art_type; CREATE TRIGGER artwork_indexer_a_del_cover_art_type AFTER DELETE ON cover_art_archive.cover_art_type FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_del_cover_art_type(); + EXECUTE PROCEDURE artwork_indexer.a_del_cover_art_type(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_release ON musicbrainz.release; CREATE TRIGGER artwork_indexer_a_del_release AFTER DELETE ON musicbrainz.release FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_del_release(); + EXECUTE PROCEDURE artwork_indexer.a_del_release(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_artist ON musicbrainz.artist; CREATE TRIGGER artwork_indexer_a_upd_artist AFTER UPDATE ON musicbrainz.artist FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_upd_artist(); + EXECUTE PROCEDURE artwork_indexer.a_upd_artist(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_release ON musicbrainz.release; CREATE TRIGGER artwork_indexer_a_upd_release AFTER UPDATE ON musicbrainz.release FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_upd_release(); + EXECUTE PROCEDURE artwork_indexer.a_upd_release(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_release_meta ON musicbrainz.release_meta; CREATE TRIGGER artwork_indexer_a_upd_release_meta AFTER UPDATE ON musicbrainz.release_meta FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_upd_release_meta(); + EXECUTE PROCEDURE artwork_indexer.a_upd_release_meta(); DROP TRIGGER IF EXISTS artwork_indexer_a_ins_release_first_release_date ON musicbrainz.release_first_release_date; CREATE TRIGGER artwork_indexer_a_ins_release_first_release_date AFTER INSERT ON musicbrainz.release_first_release_date FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_ins_release_first_release_date(); + EXECUTE PROCEDURE artwork_indexer.a_ins_release_first_release_date(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_release_first_release_date ON musicbrainz.release_first_release_date; CREATE TRIGGER artwork_indexer_a_del_release_first_release_date AFTER DELETE ON musicbrainz.release_first_release_date FOR EACH ROW - EXECUTE PROCEDURE cover_art_archive.artwork_indexer_a_del_release_first_release_date(); + EXECUTE PROCEDURE artwork_indexer.a_del_release_first_release_date(); diff --git a/sql/create_schema.sql b/sql/create_schema.sql index 59ae7f8..5b55347 100644 --- a/sql/create_schema.sql +++ b/sql/create_schema.sql @@ -1,13 +1,11 @@ CREATE SCHEMA artwork_indexer; -SET search_path = artwork_indexer; - -CREATE TYPE indexable_entity_type AS ENUM ( +CREATE TYPE artwork_indexer.indexable_entity_type AS ENUM ( 'event', -- MusicBrainz event, not to be confused with indexer events 'release' ); -CREATE TYPE event_queue_action AS ENUM ( +CREATE TYPE artwork_indexer.event_queue_action AS ENUM ( 'index', 'copy_image', 'delete_image', @@ -15,7 +13,7 @@ CREATE TYPE event_queue_action AS ENUM ( 'noop' ); -CREATE TYPE event_state AS ENUM ( +CREATE TYPE artwork_indexer.event_state AS ENUM ( -- 'queued' events are waiting to run, and are generally not -- blocked from doing so when it's their turn (based on order of -- creation), unless their parent (depends_on) has 'failed', in @@ -49,11 +47,11 @@ CREATE TYPE event_state AS ENUM ( 'completed' ); -CREATE TABLE event_queue ( +CREATE TABLE artwork_indexer.event_queue ( id BIGSERIAL, - state event_state NOT NULL DEFAULT 'queued', - entity_type indexable_entity_type NOT NULL, - action event_queue_action NOT NULL, + state artwork_indexer.event_state NOT NULL DEFAULT 'queued', + entity_type artwork_indexer.indexable_entity_type NOT NULL, + action artwork_indexer.event_queue_action NOT NULL, message JSONB NOT NULL, depends_on BIGINT[], created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), @@ -64,20 +62,20 @@ CREATE TABLE event_queue ( last_updated TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -CREATE TABLE event_failure_reason ( +CREATE TABLE artwork_indexer.event_failure_reason ( event BIGINT NOT NULL, failure_reason TEXT NOT NULL, created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -ALTER TABLE event_queue +ALTER TABLE artwork_indexer.event_queue ADD CONSTRAINT event_queue_pkey PRIMARY KEY (id); -ALTER TABLE event_failure_reason +ALTER TABLE artwork_indexer.event_failure_reason ADD CONSTRAINT event_failure_reason_fk_event FOREIGN KEY (event) - REFERENCES event_queue(id) + REFERENCES artwork_indexer.event_queue(id) ON DELETE CASCADE; --- MusicBrainz Server will sometimes publish the same message multiple @@ -85,16 +83,16 @@ ALTER TABLE event_failure_reason --- across multiple statements. It's therefore useful to enforce that --- queued index events be unique. CREATE UNIQUE INDEX event_queue_idx_queued_uniq - ON event_queue (entity_type, action, message) + ON artwork_indexer.event_queue (entity_type, action, message) WHERE state = 'queued'; CREATE INDEX event_queue_idx_state_created - ON event_queue (state, created); + ON artwork_indexer.event_queue (state, created); CREATE INDEX event_failure_reason_idx_event - ON event_failure_reason (event, created); + ON artwork_indexer.event_failure_reason (event, created); -CREATE OR REPLACE FUNCTION b_upd_event_queue() +CREATE OR REPLACE FUNCTION artwork_indexer.b_upd_event_queue() RETURNS TRIGGER AS $$ BEGIN IF OLD.last_updated = NEW.last_updated THEN @@ -105,5 +103,5 @@ END; $$ LANGUAGE 'plpgsql'; CREATE TRIGGER b_upd_event_queue - BEFORE UPDATE ON event_queue - FOR EACH ROW EXECUTE FUNCTION b_upd_event_queue(); + BEFORE UPDATE ON artwork_indexer.event_queue + FOR EACH ROW EXECUTE FUNCTION artwork_indexer.b_upd_event_queue(); diff --git a/sql/eaa_functions.sql b/sql/eaa_functions.sql index fec9310..a39e913 100644 --- a/sql/eaa_functions.sql +++ b/sql/eaa_functions.sql @@ -1,8 +1,6 @@ -- Automatically generated, do not edit. -SET LOCAL search_path = event_art_archive; - -CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_event_art() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_event_art() RETURNS trigger AS $$ DECLARE event_gid UUID; BEGIN @@ -17,7 +15,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_event_art() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_event_art() RETURNS trigger AS $$ DECLARE suffix TEXT; old_event_gid UUID; @@ -64,7 +62,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_event_art() +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_event_art() RETURNS trigger AS $$ DECLARE suffix TEXT; @@ -84,7 +82,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_ins_event_art_type() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_ins_event_art_type() RETURNS trigger AS $$ DECLARE event_gid UUID; BEGIN @@ -100,7 +98,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_event_art_type() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_event_art_type() RETURNS trigger AS $$ DECLARE event_gid UUID; BEGIN @@ -120,7 +118,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_del_event() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_del_event() RETURNS trigger AS $$ BEGIN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) VALUES ('event', 'deindex', jsonb_build_object('gid', OLD.gid)) @@ -138,7 +136,7 @@ BEGIN END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION artwork_indexer_a_upd_event() RETURNS trigger AS $$ +CREATE OR REPLACE FUNCTION artwork_indexer.a_upd_event() RETURNS trigger AS $$ BEGIN IF (OLD.name != NEW.name) THEN INSERT INTO artwork_indexer.event_queue (entity_type, action, message) ( diff --git a/sql/eaa_triggers.sql b/sql/eaa_triggers.sql index cb4f414..e16b963 100644 --- a/sql/eaa_triggers.sql +++ b/sql/eaa_triggers.sql @@ -1,6 +1,5 @@ -- Automatically generated, do not edit. -SET LOCAL search_path = 'event_art_archive'; SET LOCAL client_min_messages = warning; -- We drop the triggers first to simulate "CREATE OR REPLACE," @@ -10,41 +9,41 @@ DROP TRIGGER IF EXISTS artwork_indexer_a_ins_event_art ON event_art_archive.even CREATE TRIGGER artwork_indexer_a_ins_event_art AFTER INSERT ON event_art_archive.event_art FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_ins_event_art(); + EXECUTE PROCEDURE artwork_indexer.a_ins_event_art(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_event_art ON event_art_archive.event_art; CREATE TRIGGER artwork_indexer_a_upd_event_art AFTER UPDATE ON event_art_archive.event_art FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_upd_event_art(); + EXECUTE PROCEDURE artwork_indexer.a_upd_event_art(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_event_art ON event_art_archive.event_art; CREATE TRIGGER artwork_indexer_a_del_event_art AFTER DELETE ON event_art_archive.event_art FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_del_event_art(); + EXECUTE PROCEDURE artwork_indexer.a_del_event_art(); DROP TRIGGER IF EXISTS artwork_indexer_a_ins_event_art_type ON event_art_archive.event_art_type; CREATE TRIGGER artwork_indexer_a_ins_event_art_type AFTER INSERT ON event_art_archive.event_art_type FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_ins_event_art_type(); + EXECUTE PROCEDURE artwork_indexer.a_ins_event_art_type(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_event_art_type ON event_art_archive.event_art_type; CREATE TRIGGER artwork_indexer_a_del_event_art_type AFTER DELETE ON event_art_archive.event_art_type FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_del_event_art_type(); + EXECUTE PROCEDURE artwork_indexer.a_del_event_art_type(); DROP TRIGGER IF EXISTS artwork_indexer_a_del_event ON musicbrainz.event; CREATE TRIGGER artwork_indexer_a_del_event AFTER DELETE ON musicbrainz.event FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_del_event(); + EXECUTE PROCEDURE artwork_indexer.a_del_event(); DROP TRIGGER IF EXISTS artwork_indexer_a_upd_event ON musicbrainz.event; CREATE TRIGGER artwork_indexer_a_upd_event AFTER UPDATE ON musicbrainz.event FOR EACH ROW - EXECUTE PROCEDURE event_art_archive.artwork_indexer_a_upd_event(); + EXECUTE PROCEDURE artwork_indexer.a_upd_event();