UserFrosting
UserFrosting copied to clipboard
bake command should present option to skip creating root user
In applications with an extended user model, creation of the root user may depend on the presence of seed data in other tables. Since seeding has now been separated from migrations, seeds are no longer run before the root account is created (which makes sense). But if the user model has been extended to include fields that rely on a foreign key, then trying to create the user before that seed data has been inserted will raise a FK constraint error.
For example, if my user model has been extended to have a required company_id
foreign key, but the default companies have not been added yet by the seeder, then I will get an error when trying to create the root user.
Suggested approach is to simply give the option of skipping root user creation in the bake
command, so that you can come back and run create-admin
separately after running seed
.
Actually, I think the best solution is to simply separate create-admin
from bake
.
They were linked together at first because bake
was our installation command. But bake is also used for other stuff, which are run at many point in the life of a UserFrosting app.
However, in the meantime, you could add a custom step to the bake command.
Makes sense. create-admin
is basically an interactive seed command.