dex-backend icon indicating copy to clipboard operation
dex-backend copied to clipboard

Update the seed to check to update roles & users

Open RubenFricke opened this issue 4 years ago • 3 comments

Describe the bug Users are not updated in when something changes in the seed and the application does not instantiate the database. So the seed will only execute when there are no users stored in the database. There already is some code that could help to accomplish this. It can be found in the HelperClass folder in the API layer.

Expected behavior An possible solution could be to check if the user exists in the database. Update the user if it's any different than in the seed.

Additional context The current logic to execute the seed in the startup

            {
                // seed roles
                context.AddRange(Seed.SeedRoles());
                context.SaveChanges();
            }
            List<Role> roles = context.Role.ToList();
            if(!context.User.Any())
            {
                // seed admin
                context.User.Add(Seed.SeedAdminUser(roles));
                context.SaveChanges();
            }

RubenFricke avatar Jan 31 '21 10:01 RubenFricke