Skip to content
Snippets Groups Projects
Commit 93670dc4 authored by Jiri Sadek's avatar Jiri Sadek
Browse files

Merge branch 'upgrade-script' into release/2.57

parents 7fb7bbd1 8411aaf9
No related branches found
Tags 2.59.2-rc1
No related merge requests found
Showing
with 209 additions and 76 deletions
---
--- don't forget to update database schema version
---
UPDATE enum_parameters SET val = '2.57.0' WHERE id = 1;
CREATE TABLE mail_template_messenger_migration
(
mail_type_id INTEGER,
......
CREATE SCHEMA IF NOT EXISTS notification AUTHORIZATION fred;
ALTER TABLE notification_queue
SET SCHEMA notification;
ALTER TYPE notified_event
SET SCHEMA notification;
CREATE TYPE notification.RECIPIENT_GROUP AS ENUM
(
'admin',
'tech',
'generic',
'additional'
);
CREATE TYPE notification.MESSAGE_TYPE AS ENUM
(
'email',
'letter',
'sms'
);
CREATE TABLE notification.object_state_changes
(
object_state_id INTEGER NOT NULL CONSTRAINT notifcation_object_state_changes_email_object_state_id_fkey REFERENCES object_state (id),
recipient_group notification.RECIPIENT_GROUP NOT NULL,
message_type notification.MESSAGE_TYPE NOT NULL,
CONSTRAINT object_state_changes_email_pkey PRIMARY KEY(object_state_id, recipient_group, message_type)
);
COMMENT ON TABLE notification.object_state_changes IS 'store information about successfull notification of object state changes';
COMMENT ON COLUMN notification.object_state_changes.object_state_id IS 'which object state change triggered notification';
COMMENT ON COLUMN notification.object_state_changes.recipient_group IS 'the group of recipients of the notification';
INSERT INTO notification.object_state_changes (
SELECT ns.state_id,
CASE nsm.emails
WHEN 1 THEN 'admin'::notification.RECIPIENT_GROUP
WHEN 2 THEN 'tech'::notification.RECIPIENT_GROUP
WHEN 3 THEN 'generic'::notification.RECIPIENT_GROUP
WHEN 4 THEN 'additional'::notification.RECIPIENT_GROUP
END AS recipient_group,
'email'::notification.MESSAGE_TYPE
FROM notify_statechange ns
LEFT JOIN notify_statechange_map nsm ON ns.type = nsm.id
);
CREATE TABLE notification.contact_data_reminder
(
reminder_date DATE NOT NULL,
contact_id INTEGER NOT NULL CONSTRAINT contact_data_reminder_contact_id_fkey REFERENCES object_registry(id),
message_ident TEXT NOT NULL,
CONSTRAINT contact_data_reminder_pkey PRIMARY KEY(reminder_date, contact_id)
);
COMMENT ON TABLE notification.contact_data_reminder IS 'store information about successfull notification of contact data reminder';
COMMENT ON COLUMN notification.contact_data_reminder.reminder_date IS 'date of notification';
COMMENT ON COLUMN notification.contact_data_reminder.contact_id IS 'data of which contact were subject of the notification';
COMMENT ON COLUMN notification.contact_data_reminder.message_ident IS 'ident of the notification message';
INSERT INTO notification.contact_data_reminder (reminder_date, contact_id, message_ident)
SELECT reminder_date, contact_id, message_id::TEXT
FROM reminder_contact_message_map rcmm;
CREATE OR REPLACE FUNCTION set_additional_contacts_notification()
RETURNS TRIGGER AS
$$
......@@ -72,7 +141,40 @@ BEGIN
END
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS tr_set_additional_contacts_notification ON notification.object_state_changes;
CREATE TRIGGER tr_set_additional_contacts_notification
BEFORE INSERT ON notification.object_state_changes
FOR EACH ROW EXECUTE PROCEDURE set_additional_contacts_notification();
INSERT INTO notification.object_state_additional_contact
(object_id,
state_flag_id,
valid_from,
type,
contacts,
object_state_id)
SELECT noudae.domain_id,
eos.id,
dh.exdate::TIMESTAMP,
'email_address'::notification.CONTACT_TYPE,
ARRAY_AGG(DISTINCT LOWER(noudae.email)),
MAX(noudae.state_id)
FROM enum_object_states eos,
notify_outzone_unguarded_domain_additional_email noudae
JOIN domain_history dh ON dh.id = noudae.domain_id
JOIN history h ON h.id = dh.historyid
WHERE eos.name = 'outzoneUnguardedWarning' AND
h.valid_from <= noudae.crdate AND (h.valid_to IS NULL OR noudae.crdate < h.valid_to)
GROUP BY noudae.domain_id, dh.exdate, eos.id;
INSERT INTO domain_lifecycle_parameters (
valid_for_exdate_after,
expiration_notify_period,
outzone_unguarded_email_warning_period,
expiration_dns_protection_period,
expiration_letter_warning_period,
expiration_registration_protection_period,
validation_notify1_period,
validation_notify2_period)
VALUES (NOW()::DATE - '33 DAYS'::INTERVAL, '-30DAYS', '25DAYS', '30DAYS', '56DAYS', '61DAYS', '-30DAYS', '-15DAYS');
......@@ -40,3 +40,27 @@ DROP FUNCTION IF EXISTS migrate_mail_archive_response_to_json_impl;
DROP FUNCTION IF EXISTS helper_add_old_new_pair;
DROP FUNCTION IF EXISTS helper_add_old_new_pair_disclose;
DROP FUNCTION IF EXISTS migrate_mail_header;
DELETE FROM enum_parameters
WHERE name IN (
'mojeid_async_sms_generation',
'mojeid_async_letter_generation',
'mojeid_async_email_generation');
COMMENT ON TABLE enum_parameters IS
'Table of system operational parameters.
Meanings of parameters:
1 - model version - for checking data model version and for applying upgrade scripts
2 - tld list version - for updating table enum_tlds by data from url
9 - regular day procedure period - used to identify hour when objects are deleted and domains
are moving outzone
10 - regular day procedure zone - used to identify time zone in which parameter 9 is specified
11 - change state of objects other than domain to deleteCandidate after specified period of time in months
during which object was neither linked to other object nor updated
12 - protection period of deleted object handle (contact, nsset, keyset) in months
13 - a suffix in object_registry roid string, should match pattern \w{1,8}
14 - to identify hour when domains are moving outzone in number of hours relative to date of operation
19 - opportunity window in days before current ENUM domain validation expiration for new ENUM domain validation
to be appended after current ENUM domain validation';
INSERT INTO domain_lifecycle_parameters (
valid_for_exdate_after,
expiration_notify_period,
outzone_unguarded_email_warning_period,
expiration_dns_protection_period,
expiration_letter_warning_period,
expiration_registration_protection_period,
validation_notify1_period,
validation_notify2_period)
VALUES (NOW()::DATE - '33 DAYS'::INTERVAL, '-30DAYS', '25DAYS', '30DAYS', '56DAYS', '61DAYS', '-30DAYS', '-15DAYS');
../sql/notification_contact_data_reminder.sql
\ No newline at end of file
INSERT INTO notification.contact_data_reminder (reminder_date, contact_id, message_ident)
SELECT reminder_date, contact_id, message_id::TEXT
FROM reminder_contact_message_map rcmm;
CREATE SCHEMA IF NOT EXISTS notification AUTHORIZATION fred;
ALTER TABLE notification_queue
SET SCHEMA notification;
ALTER TYPE notified_event
SET SCHEMA notification;
INSERT INTO notification.object_state_additional_contact
(object_id,
state_flag_id,
valid_from,
type,
contacts,
object_state_id)
SELECT noudae.domain_id,
eos.id,
dh.exdate::TIMESTAMP,
'email_address'::notification.CONTACT_TYPE,
ARRAY_AGG(DISTINCT LOWER(noudae.email)),
MAX(noudae.state_id)
FROM enum_object_states eos,
notify_outzone_unguarded_domain_additional_email noudae
JOIN domain_history dh ON dh.id = noudae.domain_id
JOIN history h ON h.id = dh.historyid
WHERE eos.name = 'outzoneUnguardedWarning' AND
h.valid_from <= noudae.crdate AND (h.valid_to IS NULL OR noudae.crdate < h.valid_to)
GROUP BY noudae.domain_id, dh.exdate, eos.id;
INSERT INTO notification.object_state_changes (
SELECT ns.state_id,
CASE nsm.emails
WHEN 1 THEN 'admin'::notification.RECIPIENT_GROUP
WHEN 2 THEN 'tech'::notification.RECIPIENT_GROUP
WHEN 3 THEN 'generic'::notification.RECIPIENT_GROUP
WHEN 4 THEN 'additional'::notification.RECIPIENT_GROUP
END AS recipient_group,
'email'::notification.MESSAGE_TYPE
FROM notify_statechange ns
LEFT JOIN notify_statechange_map nsm ON ns.type = nsm.id
);
../sql/notification_object_state_changes.sql
\ No newline at end of file
DELETE FROM enum_parameters
WHERE name IN (
'mojeid_async_sms_generation',
'mojeid_async_letter_generation',
'mojeid_async_email_generation');
COMMENT ON TABLE enum_parameters IS
'Table of system operational parameters.
Meanings of parameters:
1 - model version - for checking data model version and for applying upgrade scripts
2 - tld list version - for updating table enum_tlds by data from url
9 - regular day procedure period - used to identify hour when objects are deleted and domains
are moving outzone
10 - regular day procedure zone - used to identify time zone in which parameter 9 is specified
11 - change state of objects other than domain to deleteCandidate after specified period of time in months
during which object was neither linked to other object nor updated
12 - protection period of deleted object handle (contact, nsset, keyset) in months
13 - a suffix in object_registry roid string, should match pattern \w{1,8}
14 - to identify hour when domains are moving outzone in number of hours relative to date of operation
19 - opportunity window in days before current ENUM domain validation expiration for new ENUM domain validation
to be appended after current ENUM domain validation';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment