Global Storage Object, with no User ID - Error

Hey guys,

I want to have a storage object for platform settings, which can’t have a user_id. In the docs this seem to be possible, but however when I tried it, it throws this error:

ERROR: foreign key violation: value ['00000000-0000-0000-0000-000000000000'] not found in users@primary [id]

I tried to write it like this:

local storage = {{
    collection = "platform",
    key = "settings",
    value = {
        version = "1.0.0"
    },
    permission_read = 2, 
    permission_write = 1
}}
local success, err = pcall(nk.storage_write, storage)

Which may be the issue here?

Thank you lots!

@vladmustiata That does work as you’d expect, but it seems you’ve deleted the root user ID. This is set up by Nakama’s database migrations for exactly this use case, but if you change DB contents outside Nakama’s console you may have deleted it by accident.

Check if your users table has a user with the ID 00000000-0000-0000-0000-000000000000. If it doesn’t add it back.

2 Likes

Yeah, I’ve cleared all the users from DB at one point. Thanks for the tip. :slight_smile:

If you’re looking to clear users from the DB while you’re in development you should use the developer console. Go to the Users tab and there’s a “Delete All” button near the top-right of the page. That function knows not to delete the system user. :+1:

1 Like