From: APTX Date: Tue, 9 Apr 2013 12:46:23 +0000 (+0200) Subject: Make rule names more descriptive. Some rules got overridden by accident X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=9bc3fd3e9b50e5fca04ed72b19f2217241ce82e1;p=localmylist.git Make rule names more descriptive. Some rules got overridden by accident --- diff --git a/localmylist/share/schema/schema.sql b/localmylist/share/schema/schema.sql index 6e1c155..592852a 100644 --- a/localmylist/share/schema/schema.sql +++ b/localmylist/share/schema/schema.sql @@ -262,7 +262,7 @@ CREATE VIEW rename_data AS JOIN file_location fl ON fl.fid = f.fid; -- WHEN (OLD.* IS DISTINCT FROM NEW.*) <- means if anything changed -CREATE RULE update_anime_rule AS +CREATE OR REPLACE RULE anime_update_rename_rule AS ON UPDATE TO anime WHERE old.aid = new.aid AND (old.title_english <> new.title_english OR old.title_romaji <> new.title_romaji OR old.title_kanji <> new.title_kanji OR old.description <> new.description OR old.year <> new.year OR old.start_date <> new.start_date OR old.end_date <> new.end_date OR old.type::text <> new.type::text OR old.total_episode_count <> new.total_episode_count OR old.highest_epno <> new.highest_epno OR old.rating <> new.rating OR old.votes <> new.votes OR old.temp_rating <> new.temp_rating OR old.temp_votes <> new.temp_votes) @@ -270,7 +270,7 @@ CREATE RULE update_anime_rule AS FROM file f WHERE f.fid = fl.fid AND f.aid = old.aid; -CREATE RULE update_episode_rule AS +CREATE OR REPLACE RULE episode_update_rename_rule AS ON UPDATE TO episode WHERE old.eid = new.eid AND (old.aid <> new.aid OR old.epno <> new.epno OR old.title_english <> new.title_english OR old.title_romaji <> new.title_romaji OR old.title_kanji <> new.title_kanji OR old.length <> new.length OR old.airdate <> new.airdate OR old.state <> new.state OR old.type <> new.type OR old.recap <> new.recap OR old.rating <> new.rating OR old.votes <> new.votes) @@ -278,7 +278,7 @@ CREATE RULE update_episode_rule AS FROM file f WHERE f.fid = fl.fid AND f.eid = old.eid; -CREATE RULE update_file_rule AS +CREATE OR REPLACE RULE file_update_rename_rule AS ON UPDATE TO file WHERE old.fid = new.fid AND (old.eid <> new.eid OR old.aid <> new.aid OR old.gid <> new.gid OR old.ed2k <> new.ed2k OR old.size <> new.size OR old.length <> new.length OR old.extension::text <> new.extension::text OR old.group_name <> new.group_name OR old.group_name_short <> new.group_name_short OR old.crc <> new.crc OR old.release_date <> new.release_date OR old.version <> new.version OR old.censored <> new.censored OR old.source::text <> new.source::text OR old.quality_id <> new.quality_id OR old.quality::text <> new.quality::text OR old.resolution::text <> new.resolution::text OR old.video_codec::text <> new.video_codec::text OR old.audio_codec::text <> new.audio_codec::text OR old.audio_language::text <> new.audio_language::text OR old.subtitle_language::text <> new.subtitle_language::text OR old.aspect_ratio::text <> new.aspect_ratio::text) @@ -300,8 +300,7 @@ CREATE RULE file_episode_rel_ignore_duplicate AS ON INSERT TO file_episode_rel W COMMENT ON RULE file_episode_rel_ignore_duplicate ON file_episode_rel IS 'Entries to this table are duplicated in exports'; CREATE RULE file_location_ignore_duplicate AS ON INSERT TO file_location WHERE (EXISTS (SELECT 1 FROM file_location WHERE (file_location.fid = new.fid AND file_location.host_id = new.host_id AND file_location.path = new.path))) DO INSTEAD NOTHING; -CREATE RULE file_location_update_rule AS ON UPDATE TO file_location DO NOTIFY rename_data_changed; -CREATE RULE new_file_location_rule AS ON INSERT TO file_location DO NOTIFY rename_data_changed; +CREATE RULE file_location_insert_rename_rule AS ON INSERT TO file_location DO NOTIFY rename_data_changed; CREATE RULE new_pending_request_rule AS ON INSERT TO pending_request DO NOTIFY new_pending_request; @@ -313,31 +312,31 @@ COMMENT ON RULE unknown_file_ignore_duplicate ON unknown_file IS 'Adding the sam CREATE RULE new_pending_mylist_update_rule AS ON INSERT TO pending_mylist_update DO NOTIFY new_pending_mylist_update; -- Add rules -CREATE OR REPLACE RULE anime_insert_rule AS +CREATE OR REPLACE RULE anime_insert_notify_rule AS ON INSERT TO anime DO SELECT pg_notify('rename_data_changed', ''), pg_notify('anime_insert', new.aid::text); -CREATE OR REPLACE RULE episode_insert_rule AS +CREATE OR REPLACE RULE episode_insert_notify_rule AS ON INSERT TO episode DO SELECT pg_notify('rename_data_changed', ''), pg_notify('episode_insert', new.eid::text || ',' || new.aid::text); -CREATE OR REPLACE RULE file_insert_rule AS +CREATE OR REPLACE RULE file_insert_notify_rule AS ON INSERT TO file DO SELECT pg_notify('rename_data_changed', ''), pg_notify('file_insert', new.fid::text || ',' || new.eid::text || ',' || new.aid::text); -CREATE OR REPLACE RULE file_location_insert_rule AS +CREATE OR REPLACE RULE file_location_insert_notify_rule AS ON INSERT TO file_location DO SELECT pg_notify('file_location_insert', new.location_id::text); -- Update rules -CREATE OR REPLACE RULE anime_update_rule AS +CREATE OR REPLACE RULE anime_update_notify_rule AS ON UPDATE TO anime DO SELECT pg_notify('anime_update', new.aid::text); -CREATE OR REPLACE RULE episode_update_rule AS +CREATE OR REPLACE RULE episode_update_notify_rule AS ON UPDATE TO episode DO SELECT pg_notify('episode_update', new.eid::text || ',' || new.aid::text); -CREATE OR REPLACE RULE file_update_rule AS +CREATE OR REPLACE RULE file_update_notify_rule AS ON UPDATE TO file DO SELECT pg_notify('file_update', new.fid::text || ',' || new.eid::text || ',' || new.aid::text); -CREATE OR REPLACE RULE file_location_update_rule AS +CREATE OR REPLACE RULE file_location_update_notify_rule AS ON UPDATE TO file_location DO SELECT pg_notify('file_location_update', new.location_id::text || ',' || new.fid::text);