UserFrosting icon indicating copy to clipboard operation
UserFrosting copied to clipboard

bake command should present option to skip creating root user

Open alexweissman opened this issue 4 years ago • 3 comments

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.

alexweissman avatar May 06 '20 22:05 alexweissman

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.

lcharette avatar May 06 '20 22:05 lcharette

However, in the meantime, you could add a custom step to the bake command.

lcharette avatar May 06 '20 22:05 lcharette

Makes sense. create-admin is basically an interactive seed command.

alexweissman avatar May 07 '20 01:05 alexweissman