# Cannot edit existing emails after upgrade from Mautic 3 to 4.4.5

**URL:** <https://forum.mautic.org/t/cannot-edit-existing-emails-after-upgrade-from-mautic-3-to-4-4-5/26538>\
**Category:** Mautic 4 Install/Upgrade Support\
**Created:** [December 28, 2022, 9:20pm UTC](https://forum.mautic.org/t/cannot-edit-existing-emails-after-upgrade-from-mautic-3-to-4-4-5/26538 "2022-12-28T21:20:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mneumann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mneumann/32/2512_2.png) [@mneumann](https://forum.mautic.org/u/mneumann)\
**Post date:** [December 28, 2022, 9:20pm UTC](https://forum.mautic.org/t/cannot-edit-existing-emails-after-upgrade-from-mautic-3-to-4-4-5/26538/1 "2022-12-28T21:20:33Z")

</div>

**Your software**  
_My PHP version is_ : PHP 7.4.33  
_My MySQL/MariaDB version is_ (delete as applicable): 5.7.39-42

**Updating/Installing Errors**  
_I am_ (delete as applicable): Updating  
_Upgrading/installing via_ (delete as applicable) : Command Line

_These errors are showing in the installer_ :

_These errors are showing in the Mautic log_ :  
[2022-12-28 19:55:03] console.CRITICAL: Error thrown while running command “doctrine:migrations:migrate --quiet --no-interaction”. Message: “An exception occurred while executing ‘ALTER TABLE oauth2\_clients ADD CONSTRAINT FK\_CLIENT\_ROLE FOREIGN KEY (role\_id) REFERENCES roles (id)’: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint” {“exception”:“[object] (Doctrine\DBAL\Exception\DriverException(code: 0): An exception occurred while executing ‘ALTER TABLE oauth2\_clients ADD CONSTRAINT FK\_CLIENT\_ROLE FOREIGN KEY (role\_id) REFERENCES roles (id)’:\n\nSQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint at /home/customer/www/msg.saudeplena.org/public\_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:128, Doctrine\DBAL\Driver\PDO\Exception(code: HY000): SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint at /home/customer/www/msg.saudeplena.org/public\_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint at /home/customer/www/msg.saudeplena.org/public\_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:141)”,“command”:“doctrine:migrations:migrate --quiet --no-interaction”,“message”:“An exception occurred while executing ‘ALTER TABLE oauth2\_clients ADD CONSTRAINT FK\_CLIENT\_ROLE FOREIGN KEY (role\_id) REFERENCES roles (id)’:\n\nSQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint”} {“hostname”:“gfram1.siteground.biz”,“pid”:4505}

**Your problem**  
_My problem is_ :  
I was upgrading on the command line, and the first try to finish it gave an error, asking to check details in the log file, which is shown above. The second try it passed.

Just when opening existing emails, I cannot edit them. The same happens if I clone existing emails. On my other instances I could resolve it by putting on the beginning of each email. This time it did not help to resolve the problem. The button for opening the GrapeJS editor is greyed out for most of the existing emails. Seems I can create new emails without any problems.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [December 29, 2022, 7:58am UTC](https://forum.mautic.org/t/cannot-edit-existing-emails-after-upgrade-from-mautic-3-to-4-4-5/26538/2 "2022-12-29T07:58:13Z")

</div>

Hi, the template files change between M3 and M4.  
You need to define grapesjs builder as an array the template config.

Here is the reference what needs to be changed for each template you use:

> **[Email & Landing Page Builder](https://docs.mautic.org/en/builders#templates)**
>
> Introduction. Since Mautic 3.3, Mautic has shipped with an updated, modern builder for creating emails and landing pages. In Mautic 4.0 it's the default builder.. . . To use your existing templates with the new builder, you need to add one line to...

---

<div class="post-metadata">

**Author:** ![mneumann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mneumann/32/2512_2.png) [@mneumann](https://forum.mautic.org/u/mneumann)\
**Post date:** [December 30, 2022, 1:27pm UTC](https://forum.mautic.org/t/cannot-edit-existing-emails-after-upgrade-from-mautic-3-to-4-4-5/26538/3 "2022-12-30T13:27:20Z")

</div>

Actually I have no problem with creating new emails using the templates, I have a problem with opening emails I have been writing before. Found out now that he changed them all to the code mode template, and I have just the HTML under advanced settings. Just under Mautic 3 they have been opening fine with GapeJS. What had happened to my emails, and how can I revert that?
