# Unable to restore/update discourse (PG::InvalidTextRepresentation: ERROR: invalid input syntax for type integer: "\[\]")

**URL:** https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828
**Category:** Support
**Created:** [June 13, 2022, 4:41pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828 "2022-06-13T16:41:19Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Spitap](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Spitap](https://meta.discourse.org/u/Spitap)
#### Post date: [June 13, 2022, 4:41pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/1 "2022-06-13T16:41:19Z")

</div>

Hi !

I have an instance currently running on 2.9.0.beta4, and I needed to migrate it, so I did the basic backup/restore, but restore failed on the new instance. I decided then to try to update the original instance, but it failed also. Both failed, seemingly for the same reason, during the db:migrate command.

Update error : [https://pastebin.com/raw/sQrnMe27](https://pastebin.com/raw/sQrnMe27)  
Restore error : [https://pastebin.com/raw/idWYmEFq](https://pastebin.com/raw/idWYmEFq)

Thanks for the help !

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 13, 2022, 5:16pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/3 "2022-06-13T17:16:17Z")

</div>

Looks like it may be a 🐛

This looks to me like it’s in core, but the standard question is Do you have any non-standard plugins?

---

<div class="post-metadata">

### Author: ![Spitap](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Spitap](https://meta.discourse.org/u/Spitap)
#### Post date: [June 13, 2022, 5:36pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/4 "2022-06-13T17:36:16Z")

</div>

No, it’s a vanilla one 🙂

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 13, 2022, 5:48pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/5 "2022-06-13T17:48:05Z")

</div>

I had a similar error on my test site where I had some errant data in my `selectable_avatar` site setting, and had to update it through the rails console.

Are you comfortable using the rails console? If so, could you run this and see what it says:

`SiteSetting.where(data_type:17)`

---

<div class="post-metadata">

### Author: ![Spitap](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Spitap](https://meta.discourse.org/u/Spitap)
#### Post date: [June 13, 2022, 5:51pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/6 "2022-06-13T17:51:11Z")

</div>

I’m not sure if I’ve done it correctly, but here is what I get :

```plaintext
=> #<ActiveRecord::Relation [#<SiteSetting id: 56, name: "selectable_avatars", data_type: 17, value: "[]", created_at: "2022-06-07 04:30:35.458837000 +0000", updated_at: "2022-06-08 08:14:54.196037000 +0000">]>

```

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 13, 2022, 5:54pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/7 "2022-06-13T17:54:55Z")

</div>

I think you should be able to run `SiteSetting.selectable_avatars = ""` (from the rails console again), and then be good for a rebuild.

---

<div class="post-metadata">

### Author: ![Spitap](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Spitap](https://meta.discourse.org/u/Spitap)
#### Post date: [June 13, 2022, 6:05pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/8 "2022-06-13T18:05:04Z")

</div>

Currently, rebuilding and just passed the stressful db migrate command, so I guess this one is fixed.  
Thank you both of you for your quick help !

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 13, 2022, 7:41pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/9 "2022-06-13T19:41:21Z")

</div>

Looks like you did it! You should see if you can get attention to this, as I’m pretty sure that migration is _supposed_ to migrate those selectable avatars to the new format.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 13, 2022, 8:05pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/10 "2022-06-13T20:05:05Z")

</div>

> [@pfaffman](#):
>
> that migration is _supposed_ to migrate those selectable avatars to the new format.

It is, and it’s worked in every other case we’ve seen. `[]` isn’t a valid value, even in the old format, so this particular case is quite surprising. Maybe it’s left over from some manual work on the console, or a bad import 🤔

If we get more reports, we’ll be sure to add an automated fix for this case.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 13, 2022, 8:07pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/11 "2022-06-13T20:07:07Z")

</div>

> [@david](#):
>
> `[]` isn’t a valid value,

Ah. Right. Usually when I get that error, it’s becuase I messed up such that I was accessing the wrong variable or something. But maybe that was the state that it was left in after all of the other ones had been deleted. But, really, I wasn’t paying close enough attention. 😉

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 13, 2022, 8:10pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/12 "2022-06-13T20:10:46Z")

</div>

> [@pfaffman](#):
>
> But maybe that was the state that it was left in after all of the other ones had been deleted

Our ‘list’ settings are a thin UI over pipe-delimited strings, so in theory an empty list should be stored as an empty string. But you make a good point - maybe someone was trying to empty the list and did something like this by accident:

```plaintext
pry(main)> SiteSetting.selectable_avatars = []
=> []
pry(main)> SiteSetting.selectable_avatars
=> "[]"

```

(this is with the old format. The new format has validations to prevent this, even on the console)

---

<div class="post-metadata">

### Author: ![Spitap](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Spitap](https://meta.discourse.org/u/Spitap)
#### Post date: [June 13, 2022, 8:38pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/13 "2022-06-13T20:38:58Z")

</div>

> [@david](#):
>
> Maybe it’s left over from some manual work on the console, or a bad import

Well in our case, the forum was set up at the beginning of this month, and no interactions with the console whatsoever (nor imports). In fact, I’ve discovered rails console today 😄

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 13, 2022, 8:39pm UTC](https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828/14 "2022-07-13T20:39:53Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
