Skip to content

Issue with default related object in directus_users #66

Description

@MrGreenTea

So this might be a niche issue but I wanted to see if there is a good solution.

We have user avatars but instead of uploading a picture they choose from a collection. This collection is called Avatars. We have added a field to directus_users that references the Avatar collection in a field called our_avatar. We have one default avatar that each user get's until they chose a different one. The id of this avatar is 1. So we set the default value of the our_avatar field to 1.

Now the problem: The avatars are created/imported only after the directus_users collection is updated. This causes a INVALID_FOREIGN_KEY because no Avatar with id 1 exists yet.

We haven't yet found a solution. Maybe we shouldn't really change the directus_users collection and instead have a 1-to-1 relation with something like UserCustomzation? I'd be glad to hear what you suggest. I haven't found a way to only change the default value after the avatars are imported.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions