# Ripristino fallito a causa della funzione chat\_mention mancante

**URL:** https://meta.discourse.org/t/restore-failing-with-missing-chat-mention-function/331376
**Category:** Bug
**Tags:** fixed
**Created:** [17 Ottobre 2024, 3:18pm UTC](https://meta.discourse.org/t/restore-failing-with-missing-chat-mention-function/331376 "2024-10-17T15:18:47Z")
**Posts on this page:** 1
**Showing post:** 29

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [22 Ottobre 2024, 10:25am UTC](https://meta.discourse.org/t/restore-failing-with-missing-chat-mention-function/331376/29 "2024-10-22T10:25:43Z")

</div>

Vedo il problema. Il commit [82e75c8](https://github.com/discourse/discourse/commit/82e75c8700f4da7bccba6defa11b4b69b0f8ac3c) ha creato funzioni nello schema `discourse_functions` e il commit [8016fca](https://github.com/discourse/discourse/commit/8016fcab332a2945bc3ad9676111841af3bc7fee) ha eliminato le funzioni. Quando si tenta di ripristinare un backup creato tra questi due commit su una versione successiva a `8016fca`, il ripristino fallisce.

La funzionalità di ripristino contiene una soluzione temporanea per tali problemi, ma non ha funzionato per `discourse_functions` creati da plugin. Ecco una PR che risolverà questo problema:

> <https://github.com/discourse/discourse/pull/29332>
>
> Database dumps sometimes reference functions in the \`discourse\_functions\` schema…. It's possible that some of these functions have been dropped in a newer version of Discourse. In that case, restoring an older backup will fail with a \`ERROR: function discourse\_functions.something\_something() does not exist\` error. The restore functionality contains a workaround for that problem, but it didn't work with functions created in plugin migrations.
> 
> This commit adds support for temporarily creating missing \`discourse\_functions\` from plugins. And it adds a simple check if the DB migration file even contains the required \`DROPPED\_TABLES\` or \`DROPPED\_COLUMNS\` constant. We don't need to create an instance of the DB migration class unless one of those constants is used. This makes the restore slightly faster and works around a problem with migrations that execute without \`up\` or \`down\` methods (e.g. \`BackfillChatChannelAndThreadLastMessageIdsPostMigrate\`).

---

_[View the full topic](https://meta.discourse.org/t/restore-failing-with-missing-chat-mention-function/331376)._
