mooli tayer has uploaded a new change for review. Change subject: tools: remove sql link between notification_subscribers and users. ......................................................................
tools: remove sql link between notification_subscribers and users. This is done in preperation to snmp notifications which have no connections to engine users. This includes removing subscriber_id from event_notification_hist and not using a users email instead of a notification_subscriber email. Change-Id: Ibb91d064c5ecec5b335c32636ac432299c5f96f6 Signed-off-by: Mooli Tayer <mta...@redhat.com> --- M backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java M packaging/dbscripts/event_sp.sql M packaging/dbscripts/upgrade/03_04_0620_event_notification_methods.sql 3 files changed, 18 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/24299/1 diff --git a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java index 85aeb13..47305d8 100644 --- a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java +++ b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java @@ -276,7 +276,6 @@ cs.setString(4, dispatch.getErrorMessage()); cs.setTimestamp(5, new java.sql.Timestamp(new Date().getTime())); cs.setBoolean(6, dispatch.isSuccess()); - cs.setString(7, null); cs.executeUpdate(); } catch (SQLException e) { log.error("Could not insert event notification history event", e); diff --git a/packaging/dbscripts/event_sp.sql b/packaging/dbscripts/event_sp.sql index 3087f6c..9b6c4e0 100644 --- a/packaging/dbscripts/event_sp.sql +++ b/packaging/dbscripts/event_sp.sql @@ -15,13 +15,12 @@ v_method_type CHAR(10), v_reason CHAR(255) , v_sent_at TIMESTAMP WITH TIME ZONE, - v_status BOOLEAN, - v_subscriber_id VARCHAR(100)) + v_status BOOLEAN) RETURNS VOID AS $procedure$ BEGIN -INSERT INTO event_notification_hist(audit_log_id, event_name, method_type, reason, sent_at, status, subscriber_id) - VALUES(v_audit_log_id, v_event_name, v_method_type, v_reason, v_sent_at, v_status, v_subscriber_id::uuid); +INSERT INTO event_notification_hist(audit_log_id, event_name, method_type, reason, sent_at, status) + VALUES(v_audit_log_id, v_event_name, v_method_type, v_reason, v_sent_at, v_status); END; $procedure$ LANGUAGE plpgsql; diff --git a/packaging/dbscripts/upgrade/03_04_0620_event_notification_methods.sql b/packaging/dbscripts/upgrade/03_04_0620_event_notification_methods.sql index ddace54..4187bc5 100644 --- a/packaging/dbscripts/upgrade/03_04_0620_event_notification_methods.sql +++ b/packaging/dbscripts/upgrade/03_04_0620_event_notification_methods.sql @@ -13,3 +13,18 @@ UPDATE event_subscriber SET notification_method = 'EMAIL'; ALTER TABLE event_subscriber ALTER notification_method SET NOT NULL; + +------------------------------------------------------------------------------------------ +-- Remove the connection between a subscription address and the subscribing system user -- +------------------------------------------------------------------------------------------ + +-- Up to this change if a subscriber had no email it's address was taken from the users table +-- this behaviour is removed from here on. +UPDATE event_subscriber AS es +SET method_address = u.email +FROM event_subscriber AS es2 + INNER JOIN users u ON es2.subscriber_id = u.user_id +WHERE (es.method_address is NULL OR trim(both from es.method_address) = ''); + +-- change events history table +ALTER TABLE event_notification_hist DROP COLUMN subscriber_id; -- To view, visit http://gerrit.ovirt.org/24299 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibb91d064c5ecec5b335c32636ac432299c5f96f6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: mooli tayer <mta...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches