OMP upgrade (3.1 -> 3.3) fails on table email_templates

Hi all,

I’m working on an OMP upgrade from version 3.1.0.0 to 3.3.0. Unfortunately the upgrade script fails with:

...
2022-08-11 16:05:35 [migration: PKPv3_2_1SubeditorCategoriesMigration]
2022-08-11 16:05:35 [note: docs/release-notes/README-3.2.1]
2022-08-11 16:05:35 [migration: PKPv3_3_0UpgradeMigration]
ERROR: Upgrade failed: DB: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'context_id' at row 1 (SQL: ALTER TABLE email_templates CHANGE context_id context_id BIGINT DEFAULT 0 NOT NULL)

The message seems to originate from PKPv3_3_0UpgradeMigration.php line 89:

which is commented with “// pkp/pkp-lib#6093 Don’t allow nulls (previously an upgrade workaround)”.

Looking at the table “email_templates” I indeed find:

MariaDB [omp_edr]> select * from email_templates;
+----------+-------------------------------+---------+------------+
| email_id | email_key                     | enabled | context_id |
+----------+-------------------------------+---------+------------+
|        1 | PASSWORD_RESET_CONFIRM        |       1 |       NULL |
|        2 | PASSWORD_RESET                |       1 |       NULL |
|        3 | USER_REGISTER                 |       1 |       NULL |
|        4 | USER_VALIDATE                 |       1 |       NULL |
|        5 | PUBLISH_NOTIFY                |       1 |       NULL |
|        6 | REVIEW_CONFIRM                |       1 |       NULL |
|        7 | NOTIFICATION                  |       1 |       NULL |
|        8 | NOTIFICATION_MAILLIST_WELCOME |       1 |       NULL |
+----------+-------------------------------+---------+------------+
8 rows in set (0.000 sec)

My first approach was trying to set context_id in the original database to 0 or 1 (acually I would expect the upgrade process to automatically replace NULL by 0). But I realized the column doesn’t even exists:

MariaDB [omp_edr]> select * from email_templates;
+----------+-------------------------------+------------+----------+---------+
| email_id | email_key                     | assoc_type | assoc_id | enabled |
+----------+-------------------------------+------------+----------+---------+
|        1 | PASSWORD_RESET_CONFIRM        |        512 |        1 |       1 |
|        2 | PASSWORD_RESET                |        512 |        1 |       1 |
|        3 | USER_REGISTER                 |        512 |        1 |       1 |
|        4 | USER_VALIDATE                 |        512 |        1 |       1 |
|        5 | PUBLISH_NOTIFY                |        512 |        1 |       1 |
|        6 | REVIEW_CONFIRM                |        512 |        1 |       1 |
|        7 | NOTIFICATION                  |        512 |        1 |       1 |
|        8 | NOTIFICATION_MAILLIST_WELCOME |        512 |        1 |       1 |
+----------+-------------------------------+------------+----------+---------+
8 rows in set (0.000 sec)

The column “context_id” is added in the 3.2 upgrade process by 3.2.0_preupdate_email_templates.xml

It looks like the 3.3 upgrade fails on a state left behind be the 3.2 upgrade step. Or did I miss anything?

Anyway, what would be the best work-around? Apart from the obvious path of upgrading to 3.2, adjusting the table and continueing to 3.3.

Thanks,
Ronald

Ok, just for documentation.

I meanwhile found a workaround to do the upgrade in a single step.
I modified line 25 in 3.2.0_preupdate_email_templates.xml to set context_id to 0. This way the upgrade runs smooth.