Ok another update. This sandbox instance was just fine when I added the missing function last night.
When running a restore with the SAME restore file, the error returned. I suspect something is dropping the function somewhere? Attached in a full log.
restore.txt (5.6 KB)
gerhard
(Gerhard Schlager)
October 22, 2024, 10:25am
29
I see the problem. Commit 82e75c8 created functions in the discourse_functions
schema and commit 8016fca dropped the functions. When you try to restore a backup that was created between those two commits on a version after 8016fca
, then the restore fails.
The restore functionality contains a workaround for such issues, but it didn’t work for discourse_functions
created from within plugins. Here’s a PR that will fix this:
discourse:main
← discourse:fix_restore_discourse_functions
opened 10:25AM - 22 Oct 24 UTC
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`).
2 Likes
Sbohengel
(Sibongile )
October 22, 2024, 9:45pm
31
Thank you so much I will try that as well
gerhard
(Gerhard Schlager)
October 22, 2024, 9:59pm
32
This is solved. Restoring the backup will work after you update Discourse to the latest commit.
There’s no need to create a new backup, manually create the missing function, or any of the other workarounds mentioned in this topic.
6 Likes
gerhard
(Gerhard Schlager)
Closed
October 24, 2024, 10:00pm
33
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.