[Fixed][ERROR] Migration BM 4.5 en BM 4.6

Salut,

j’ai une merdouille sur la migration en 4.6

Ce qui est remonté dans la console WEB :

OK (core is ready)
Begin upgrade
Starting SqlUpdater:2021-09-01-1@SHARD SQL:/sql/5/5.20210901_message_body_purge_sds.sql
On SQL script bundleresource://160.fwk143110009/sql/5/5.20210901_message_body_purge_sds.sql
upgrade :
ERROR: relation “t_message_body_purge_queue” does not exist
org.postgresql.util.PSQLException: ERROR: relation “t_message_body_purge_queue” does not exist
Upgrade failed

Ce qui est présent dans la log PG :

2021-11-03 10:52:26 GMT [24434]: [1-1] LOG: duration: 274.393 ms statement: COPY public.t_job_log_entry (execution_id, severity, stamp, locale, content) TO stdout;
2021-11-03 10:52:43 GMT [25064]: [1-1] ERROR: invalid input value for enum t_directory_entry_account_type: “FULL_AND_VISIO”
2021-11-03 10:52:43 GMT [25064]: [2-1] STATEMENT: WITH qp AS ( SELECT ($1::text) as kind, ($2::t_directory_entry_account_type) as account_type, ($3::text) as name, ($4::text) as nameOrEmail,($5::text) as nameOrEmailSplitted, ($6::text)
as email, ($7::text) as emailLeftPart, ($8::text) as hidden, ($9::text) as system ,($10::text) as entryuid, ($11::boolean) as archived, ($12::text) as datalocation) select item.id, item.uid, item.version, item.external_id, item.displa
yname, item.createdby, item.updatedby, item.created, item.updated, item.flags from t_container_item item, t_directory_entry dir, qp WHERE item.id = dir.item_id AND item.container_id = $13 AND ( qp.kind is null or dir.kind = ANY ( qp.kin
d )) AND ( qp.account_type is null or dir.account_type = qp.account_type ) AND ( qp.name is null or unaccent(dir.displayname) ilike qp.name) AND ( qp.nameOrEmail is null or (dir.email ilike qp.nameOrEmail or unaccent(dir.displayname) ili
ke qp.nameOrEmail)) AND ( qp.email is null or dir.email ilike qp.email) AND ( qp.hidden is null or dir.flag_hidden = false ) AND ( qp.system is null or dir.flag_system = false ) AND ( qp.entryuid is null or item.uid = ANY ( entryuid ))
AND ( qp.archived is null or dir.flag_archived = qp.archived ) AND ( qp.datalocation is null or dir.datalocation = qp.datalocation ) order by dir.displayname asc offset $14
2021-11-03 10:53:00 GMT [25082]: [1-1] ERROR: relation “t_message_body_purge_queue” does not exist
2021-11-03 10:53:00 GMT [25082]: [2-1] STATEMENT: ALTER TABLE t_message_body_purge_queue ADD COLUMN removed date

Ok,

j’ai reçu le fix par messagerie.
Mais j’attends le retour de BM pour le communiquer ou pas.

Pascal

Bonjour,
Vous pouvez vérifier avant la mise à jour que vous serez impacté en lançant la commande suivante :

PGPASSWORD=bj psql -U bj -h localhost -d bj-data -c "\d+ t_message_body_purge_queue;"

Si une description de la table est présente, vous n’êtes pas concernés par ce problème. La procédure suivante ne s’appliquera pas mais vous pouvez la jouer sans risque.

Si la table n’est pas trouvée, vous serez alors bloqués durant la mise à jour.

Voici le fix en attendant la 4.6.1:

Se connecter sur le serveur en SSH et lancer la commande suivante :

PGPASSWORD=bj psql -U bj -h localhost -d bj-data

copier coller les commandes suivantes :

-- $SHARD upgraders

-- fix for 5.20200915_lower_ics_uid.sql
drop index if exists idx_calendar_series_icsuid;
create index if not exists idx_calendar_series_lowercase_icsuid on t_calendar_series (lower(ics_uid));

-- fix for 5.20201204_mailbox_records_expire.sql

CREATE INDEX IF NOT EXISTS t_mailbox_record_last_updated_message_body_guid_item_id_idx ON t_mailbox_record (last_updated)
        INCLUDE (message_body_guid, item_id)
        WHERE (((system_flags)::bit(32) & (1<<31)::bit(32)) = (1<<31)::bit(32));

-- fix for 5.20201204_message_body_purge_queue.sql
DO $do$
BEGIN
    IF NOT EXISTS (SELECT 1 FROM pg_class WHERE relname = 't_message_body_purge_queue' AND relkind = 'r')
    THEN
        CREATE TABLE IF NOT EXISTS t_message_body_purge_queue (
                message_body_guid bytea UNIQUE PRIMARY KEY not null,
                created TIMESTAMP NOT NULL
        );
        CREATE INDEX ON t_message_body_purge_queue (created, message_body_guid);

        CREATE OR REPLACE FUNCTION trigger_message_record_purge() RETURNS trigger AS
        $trigger$
        BEGIN
            IF TG_OP = 'DELETE' THEN
                    -- Find references to other t_mailbox_record
                    -- we want to add to the purge body queue unreferenced messages
                    PERFORM 1 FROM t_mailbox_record WHERE message_body_guid = OLD.message_body_guid;
                    IF NOT FOUND THEN
                            INSERT INTO t_message_body_purge_queue (message_body_guid) VALUES (OLD.message_body_guid)
                                    ON CONFLICT(message_body_guid) DO NOTHING;
                    END IF;
            ELSIF TG_OP = 'INSERT' THEN
                    -- delete from the purge queue if present
                    DELETE FROM t_message_body_purge_queue WHERE message_body_guid = NEW.message_body_guid;
            END IF;
            RETURN NULL;
        END;
        $trigger$ LANGUAGE plpgsql;

        CREATE TRIGGER trigger_message_record_purge AFTER DELETE OR INSERT ON t_mailbox_record
                FOR EACH ROW EXECUTE PROCEDURE trigger_message_record_purge();
    END IF;
END$do$;

-- Fix for 5.20201218_message_body_purge_queue_default.sql
ALTER TABLE IF EXISTS t_message_body_purge_queue
    ALTER created SET DEFAULT now();

lancer le processus de mise à jour.