laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.71k stars 11.06k forks source link

[proposal] additional "php artisan db:create" command #2268

Closed dmitry-ivanov closed 11 years ago

dmitry-ivanov commented 11 years ago

Hi there!

Why does artisan don't have some command for database creation, independently of its scheme? F.e. "sqlite" databases require proper .sqlite file to be created before, "mysql" databases require proper mysql database exists, etc. Otherwise "php artisan migrate" just fails.

Proposition

Add something like:

php artisan db:create

Can't understand why does artisan don't have such command yet.

Thank you!

sorbing commented 11 years ago

This is a useful.

lucasmichot commented 11 years ago

:+1:

cya commented 11 years ago

That would be great!!

dmitry-udod commented 11 years ago

Good idea!

codextends commented 11 years ago

The ability to create database depends on privileges that varies from host to host, so I think it's better to leave that process outside of laravel (plus you wouldn't want to grant 'root' privileges at the application level on a server)

And technically the L4 DB Driver needs an existing database to connect, so I'm not sure it's even possible.

If you want to go without having to configure a DB, Laravel ships with an empty sqlite.database. Simply switch the driver to 'sqlite' and you have a database working in seconds ;)

sorbing commented 11 years ago

This feature would be very useful on localhost for dev environment. And especially for InnoDB engines, when to remove all tables at a time can not be. On prod server need to restrict user privileges.

L4 DB Driver needs an existing database to connect This issue should be discussed.

~ ~ ~ Данная возможность была бы очень полезна на localhost в среде разработки. И особенно для InnoDB движков, когда удалить все таблицы за один раз невозможно. А на сервере уже можно ограничить привилегии пользователя.

L4 DB Driver needs an existing database to connect Этот момент нужно обсудить.

dmitry-ivanov commented 11 years ago

The ability to create database depends on privileges that varies from host to host, so I think it's better to leave that process outside of laravel (plus you wouldn't want to grant 'root' privileges at the application level on a server)

Correct. But ability to modify database depends on privileges too, but we do have php artisan migrate command, right? :) I mean, set proper priveleges and modify app/config/database.php is must have, anyway. If you're talking about priveleges on FS (to create sqlite file for example) - we can check it and throw some exception if needed.

And technically the L4 DB Driver needs an existing database to connect, so I'm not sure it's even possible.

If I understood you right, you're talking about inability to set this command in artisan's db: command namespace? If so, feel free to add it in any other artisan's command namespace, or even to a separate command :)

If you want to go without having to configure a DB, Laravel ships with an empty sqlite.database. Simply switch the driver to 'sqlite' and you have a database working in seconds ;)

Yep. But what about other db drivers working in seconds? ;) Artisan knows all required data to create ( or try to create ) any db, independently of its driver. So does it really bad to give such an optional ability?

kirkbushell commented 11 years ago

This has come up a few times and tbh I do not think it is necessary. Agreed that permissions can (and should) be handled by each individual host/database - but considering most developers do not give any thought to table and operation-level permissions to users, this has the possibility of opening up a serious can of worms in terms of security.

That said, if create is going to be provided - so should drop.

robclancy commented 11 years ago

Robbo

dmitry-ivanov commented 11 years ago

@robclancy, thanks! ;) but your answer should be N funny pics, why just mysql?

There are four default connections present in app/config/database.php now:

Later there could be even more. What is more comfortable - run proper driver's command to create, or run common, simple and beautiful, artisan's command to create?

robclancy commented 11 years ago

You don't have to use mysql? :o Are the others are webscales?

WMeldon commented 11 years ago

This actually would be something that should be fairly easy to implement using the new Remote feature. @robclancy continues to be right, but there is no reason you can't execute remote commands using the artisan interface.

taylorotwell commented 11 years ago

Don't think we'll implement this at this time.