Mautic Community Forums

TIP: When Mautic database schema refuses to update

We’re getting ready to release version 2.0 of the Gravity Forms Mautic Add-On, and I ran into a weird issue with our Mautic installation where I could not view contacts.



I checked the log file (in the

Code:
app/logs
folder) and saw that there was a DB error that a column could not be found in a table. So I figured a schema update would do the trick.

When I tried it through the app

> by visiting
Code:
/s/upgrade/schema

it said that the schema was up-to-date. So I double-checked through the command line

>
Code:
php app/console doctrine:schema:update --dump-sql

and saw that there were indeed some updates that needed to be applied. But when I ran the schema update

>
Code:
php app/console doctrine:schema:update --force

I kept getting an error:
Quote:
An exception occurred while executing [SQL statement]...General error: 1005 Can't create table [table name]

So I decided to try executing the offending SQL statement in my database management app (Sequel Pro), and sure enough I received the same error. But, I wondered what would happen if I kept going to the next statement because maybe one of the other statements would help with the one that was choking.
Quote:

[h]Here's what I did:[/h]

1. Copied all of the statements from the SQL dump command from above and pasted them into the Sequel Pro query window. There were about 22 total.
2. Skipped over the statement that was choking (it was the first one) and executed the next statements, one-by-one, so Sequel Pro could let me know whether the statement executed successfully or had an error. If there was an error, I was able to see the error and fix it. There ended up being only one other statement with an easily fixable error.
3. Finally, I came back to the first statement that wouldn't run and tried to run it again. And it worked!

So if you're having trouble with a schema update, try executing each of the other statements one-by-one to catch any errors, then come back to the offending one.

Hope that helps someone!

We’re getting ready to release version 2.0 of the Gravity Forms Mautic Add-On, and I ran into a weird issue with our Mautic installation where I could not view contacts.

I checked the log file (in the app/logs folder) and saw that there was a DB error that a column could not be found in a table. So I figured a schema update would do the trick.

When I tried it through the app

by visiting /s/upgrade/schema

it said that the schema was up-to-date. So I double-checked through the command line

php app/console doctrine:schema:update --dump-sql

and saw that there were indeed some updates that needed to be applied. But when I ran the schema update

php app/console doctrine:schema:update --force

I kept getting an error:

So I decided to try executing the offending SQL statement in my database management app (Sequel Pro), and sure enough I received the same error. But, I wondered what would happen if I kept going to the next statement because maybe one of the other statements would help with the one that was choking.

Hope that helps someone!

That’s a good and helpful workaround!

I may add a great blogpost with additional tipps if your Mautic upgrade goes wrong: https://johnlinhart.com/blog/uh-oh-mautic-upgrade-was-not-successful

This tip is for when the specified command in that blog post does not work