<p>I have a Structure section that I converted to a Channel. I then tried to delete an Entry Type from the Control Panel and get the following error:</p>

<pre><code>{"error":"SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in '(`databasename`.`craft_structureelements`.`level` - 2)'\nThe SQL being executed was: UPDATE `craft_structureelements` SET `level`=`level`-2, `dateUpdated`='2019-05-26 04:16:54' WHERE ((`lft` &gt;= 128) AND (`rgt` &lt;= 129)) AND (`root`=21)"}
</code></pre>

<p>Upon closer inspection, I'm able to delete many of the Entries of that Entry Type if I delete them directly but there is one that I cannot delete directly which seems to be the source of the error above.</p>

<p>I have found a general discussion of <a href="https://stackoverflow.com/questions/5743069/bigint-out-of-range-error-since-mysql-5-5">a similar mysql error</a> but I haven't found any Craft specific discussion of this. As I'm trying to make the delete action from the Craft UI, the general solutions are not directly applicable.</p>

<p>Any ideas what might be going on here and what my options are to fix this and get the Entry Type in question deleted without any unexpected side effects?</p>

CC BY-SA 4.0
2019-05-27T18:17:16.157Z
The error is because somehow your `level` value is at `-2`, when that column only allows for positive integers. No idea how you ended up with a negative level, though.
Brad Bell
CC BY-SA 4.0
2019-05-28T11:42:06.717Z
@BradBell Ok. So, next when I search for any records in the `craft_structureelements` table with `level` = `-2` I don't find any records. If I search for the specific Element ID causing the issue, the `level` in the db is `1`, which is correct.  Any ideas where to look next? Could this be a miscalculation happening in PHP somehow?
Ben Parizek
CC BY-SA 4.0
2019-05-28T19:06:27.987Z
Yeah, hard to say without looking at the database.  That table uses the nested set model (https://en.wikipedia.org/wiki/Nested_set_model) for storing hierarchical data, so my guess would be that somehow that data is out of sync and a calculation is getting set to -2.
Brad Bell
CC BY-SA 4.0
2019-05-29T23:50:00.387Z
Would resaving all entries be a way to resync the data? I'm familiar with nested set but I don't think it would be simple to walk through the `lft` and `rgt` values to try to figure out what might be stored incorrectly.
Ben Parizek
CC BY-SA 4.0
2019-05-30T16:22:17.537Z
I don't think so... if you shoot an email over to support@craftcms.com, we've got a script that will let you "visualize" the structure's hierarchy to at least see what sort of shape it is in.
Brad Bell
<structure><entry-type><mysql>
Unable to delete Entry: Numeric value out of range
# Unable to delete Entry: Numeric value out of range

(Asked by: username_0 on 2019-05-26)

I have a Structure section that I converted to a Channel. I then tried to delete an Entry Type from the Control Panel and get the following error:
{"error":"SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in '(`databasename`.`craft_structureelements`.`level` - 2)'\nThe SQL being executed was: UPDATE `craft_structureelements` SET `level`=`level`-2, `dateUpdated`='2019-05-26 04:16:54' WHERE ((`lft` >= 128) AND (`rgt` <= 129)) AND (`root`=21)"}

Upon closer inspection, I'm able to delete many of the Entries of that Entry Type if I delete them directly but there is one that I cannot delete directly which seems to be the source of the error above.
I have found a general discussion of a similar mysql error but I haven't found any Craft specific discussion of this. As I'm trying to make the delete action from the Craft UI, the general solutions are not directly applicable.
Any ideas what might be going on here and what my options are to fix this and get the Entry Type in question deleted without any unexpected side effects?

**Tags:** structure, entry-type, mysql

> **Comments:**
> **username_1**: The error is because somehow your `level` value is at `-2`, when that column only allows for positive integers. No idea how you ended up with a negative level, though.  
> **username_0**: @BradBell Ok. So, next when I search for any records in the `craft_structureelements` table with `level` = `-2` I don't find any records. If I search for the specific Element ID causing the issue, the `level` in the db is `1`, which is correct.  Any ideas where to look next? Could this be a miscalculation happening in PHP somehow?  
> **username_1**: Yeah, hard to say without looking at the database.  That table uses the nested set model (https://en.wikipedia.org/wiki/Nested_set_model) for storing hierarchical data, so my guess would be that somehow that data is out of sync and a calculation is getting set to -2.  
> **username_0**: Would resaving all entries be a way to resync the data? I'm familiar with nested set but I don't think it would be simple to walk through the `lft` and `rgt` values to try to figure out what might be stored incorrectly.  
> **username_1**: I don't think so... if you shoot an email over to support@craftcms.com, we've got a script that will let you "visualize" the structure's hierarchy to at least see what sort of shape it is in.  

---

## 0 answers

