# TIP: When Mautic database schema refuses to update

**URL:** <https://forum.mautic.org/t/tip-when-mautic-database-schema-refuses-to-update/9475>\
**Category:** General Discussion\
**Created:** [September 15, 2017, 6:03am UTC](https://forum.mautic.org/t/tip-when-mautic-database-schema-refuses-to-update/9475 "2017-09-15T06:03:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![naomicbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/naomicbush/32/93_2.png) [@naomicbush](https://forum.mautic.org/u/naomicbush)\
**Post date:** [September 15, 2017, 6:03am UTC](https://forum.mautic.org/t/tip-when-mautic-database-schema-refuses-to-update/9475/1 "2017-09-15T06:03:23Z")

</div>

We’re getting ready to release **version 2.0 of the [Gravity Forms Mautic Add-On](https://gravityplus.pro/gravity-forms-mautic/)**, 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!

---

<div class="post-metadata">

**Author:** ![naomicbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/naomicbush/32/93_2.png) [@naomicbush](https://forum.mautic.org/u/naomicbush)\
**Post date:** [September 15, 2017, 6:03am UTC](https://forum.mautic.org/t/tip-when-mautic-database-schema-refuses-to-update/9475/2 "2017-09-15T06:03:23Z")

</div>

We’re getting ready to release version 2.0 of the [Gravity Forms Mautic Add-On](https://gravityplus.pro/gravity-forms-mautic/), 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

> ```auto
> 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

> ```auto
> php app/console doctrine:schema:update --force
> ```

I kept getting an error:

> [@](#):
>
> 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.

> [@](#):
>
> [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!

---

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [September 15, 2017, 9:15am UTC](https://forum.mautic.org/t/tip-when-mautic-database-schema-refuses-to-update/9475/3 "2017-09-15T09:15:19Z")

</div>

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](https://johnlinhart.com/blog/uh-oh-mautic-upgrade-was-not-successful)

---

<div class="post-metadata">

**Author:** ![naomicbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/naomicbush/32/93_2.png) [@naomicbush](https://forum.mautic.org/u/naomicbush)\
**Post date:** [September 15, 2017, 4:27pm UTC](https://forum.mautic.org/t/tip-when-mautic-database-schema-refuses-to-update/9475/4 "2017-09-15T16:27:14Z")

</div>

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