Can't update post metadata (Unable to update nested relation)

Hi everyone, I’m having troubles in production :slightly_smiling_face:

Post creation and publishing works fine (as well as the webhooks associated with the event). However, we’re unable to update the Metadata (posts_meta) for any given (published/unpublished) post without raising the following error:

“message”:“An error occurred”,
“context”: “Unable to update nested relation. [object Object]”,
“type”: “BookshelfRelationsError”,
“details”: null,
“property”: null,
“help”: null,
“id”: “18c059c0-72a9-11ea-a235-577d1046a35d”

I’m new to Ghost and recently launched a Ghost instance (v3.12) in production.
The issue I’m having certainly lies on the fact that some information from the database (MySQL) of a previous Ghost instance (v2.26), such as the “users” and “webhooks” tables were essentially copied to the database for the new, fresh instance (also MySQL).

Basically, what I did was export a dump of the old database, import it into the new one and manually truncate stuff like “posts”, “tags” and the like. Migrations look fine (I’ve checked the table to see if its updated), the ghost update command also runs fine and ghost doctor tells everything should be ok.

Taking a look at Ghost’s source code, I found this:

         * CASE: Attach id to update existing posts_meta entry for a post
         * CASE: Don't create new posts_meta entry if post meta is empty

It seems to me that the entries on the post_meta table should be automatically created to match an id on the posts table, upon post creation. That isn’t happening, my posts_meta table is empty and I’ve tried manually adding the entries to match the ids in posts with no success.

Any help is greatly appreciated.

We highly recommend following the upgrade steps as it mitigates scenarios just like this:

Can I ask why to did it that way? Was there something that you were worried about losing in the upgrade process?

To be honest, I didn’t want to tell the client we would have to recreate all the users manually, set all the permissions again etc…

We were setting up a Ghost instance for our blog in Spain and the idea was to keep the same users, permissions, roles data as the old Brazilian instance while having posts, posts_meta and tags empty.

The fresh instance (in v3.12) started with a clean database so it didn’t come to my head that it would break, specially since I didn’t copy neither posts nor posts_meta. Funny enough, this was the only thing that ended up breaking.

Are there any guidelines you can think of for hammering this problem? I’m willing to somehow force Ghost to create the entries in posts_meta table associated to the posts table himself, that looks promising (and fun).