Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any reasons why doesn't bakery create the db? #767

Closed
abdullahseba opened this issue Jul 11, 2017 · 15 comments
Closed

Any reasons why doesn't bakery create the db? #767

abdullahseba opened this issue Jul 11, 2017 · 15 comments
Labels
bakery Related to the Bakery feature core feature request Feature request installation Related to the installation process needs discussion A decision needs to be taken by the dev team wontfix This will not be worked on

Comments

@abdullahseba
Copy link
Contributor

Bakery probably should have an option to create a db during setup possibly with a one time root login for the purpose.

@alexweissman alexweissman added bakery Related to the Bakery feature core feature request Feature request installation Related to the installation process labels Jul 11, 2017
@Silic0nS0ldier
Copy link
Member

To my understanding, the built in database drivers connect directly to the database, as opposed to the system that runs the instances. If its possible though, I reckon its worth considering.

@lcharette lcharette added the needs discussion A decision needs to be taken by the dev team label Dec 16, 2017
@alexweissman
Copy link
Member

It doesn't look like Eloquent has any built-in support for creating databases; we'd have to implement our own raw queries for each type of database.

Raw queries would also be needed to add the necessary db user permissions, and we'd have to get admin credentials from the installing user so that the database could be created and permissions could be applied.

One way this could work is:

  1. Ask if this is an installation on an existing database, or if they'd like to create a new database;
  2. If they'd like to create a new one, prompt the installing user for admin credentials;
  3. Use the admin credentials to create the new database (using raw queries);
  4. Generate a new db user (e.g. userfrosting), and a random, secure password, and give that user restricted permissions to the new database;
  5. Write the database name and newly created user credentials to .env.

Would be a bit of work.

@lcharette
Copy link
Member

Would be a bit of work.

...for what benefits? I'm still not convinced why this is an issue. If it where, Laravel would support it. It's not necessary for tests anyway.

@alexweissman
Copy link
Member

Well, the benefit would be that it reduces the complexity of the install process, which is critical to new user onboarding.

@abdullahseba
Copy link
Contributor Author

As I see bakery should not be using any external libraries before composer is run.
Right now to install user frosting you have to

  1. Setup the database manually
  2. Run composer
  3. Run bakery.

All 3 items can be done by bakery in that order if it was written to do so.
All bakery has done as far as the install processes goes is combine the migrator and the assets installation.

Thats my tuppence worth put in :)

@alexweissman
Copy link
Member

Actually, Bakery can't run Composer because Bakery is autoloaded by Composer. We'd have to have a precompiled distribution of Bakery in order for that to work.

@abdullahseba
Copy link
Contributor Author

Yep bakery relies on symfony - cli too
That's the whole problem with it.
Been cli you can have an install.php or something that runs bakery at the end.

@lcharette
Copy link
Member

Plus Bakery requires Symfony dependencies to work. But Composer can run bakery commands.

RE the database... while it could be easier for noobs, it’s still IMO part of the server setup process. Like installing PHP and setting up Apache VHost. This is probably historically related to Shared Hosting where you had to create the db in cpanel (and where you where limited in the number of db you could have...). Also keep in mind if noobs uses Vagrant/Docker, the db will already be created. Even *ammp will create the dbs...

Maybe there’s an existing Composer package to do this? Otherwise, it could make a good “up for grabs” issue since it’s low priority.

@Silic0nS0ldier
Copy link
Member

Well, Bakery couldn't run Composer, but bakery can! There already is an autoload.php existence check, and getting PHP to run a command is trivial enough. The question becomes, SHOULD Bakery run composer if needed.

@alexweissman
Copy link
Member

Actually, if we had a distribution repository (see #830 (comment)), then Bakery wouldn't need to run Composer.

@Silic0nS0ldier
Copy link
Member

Yes, it would. Bakery takes commands from Sprinkles, which in turn can call on their own dependencies.

@abdullahseba
Copy link
Contributor Author

abdullahseba commented Dec 21, 2017

Adding "post-install-cmd" : "php bakery bake" to scripts in composer.json works fine.
Then you can either have a separate script or a custom bakery command to create the db.
That way as far as the user is concerned, all he has to run is composer install to setup uf.

@Silic0nS0ldier
Copy link
Member

Not a fan of messing with composer install, since the command is so heavily associated with dependency installation alone. Plus it'll interfere if all you want to run is composer install.

I do have an alternative though. Composer scripts can call other commands, including composer install (see scripts#calling-composer-commands). We could have a special "do everything" command, and retain the ability to run everything manually (which can come in handy when debugging).

@lcharette
Copy link
Member

FYI, Bakery bake was once in the post-install-cmd. But it creates another issue. When you run composer,  bake is always called whatever you do. There are scenarios when you don't want to be called automatically.

Previously, the issue was because .env and sprinkles.json weren't created by bakery, to it was baking nothing. Currently the issue is if you don't want to create the admin user (which is done by bake) when running install... which is exactly what you don't want when running composer in the Travis env.

Make it easy for newb to understand, but don't make it too easy, as they'll be lazy. Teach them how not to be lazy.

@stale
Copy link

stale bot commented Jun 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 24, 2019
@stale stale bot closed this as completed Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bakery Related to the Bakery feature core feature request Feature request installation Related to the installation process needs discussion A decision needs to be taken by the dev team wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants