It would be nice to have a db create command, so it wouldn't be necessary to create them manually.
This is useful for multiple environments, similar to what Rails does I think.
The database creation can be done through SQLAlchemy create_engine() method or SQLAlchemy Utils create_database().
Database existence checks can be done also with SQLAlchemy Utils using database_exists().
What do you think? A valid feature?
As a high level request I understand it can be useful, but I think it is complicated to have a practical implementation of this, simply because the database credentials that the application uses are usually not powerful enough to create databases. At least they shouldn't be, if you follow security best practices.
Creating/destroying databases is a task typically performed by an administrator. The credentials that the application are given are (or should be) restricted to operating on a single existing database, without the ability to create/destroy/read/write any other databases, or manage users, permissions, etc.
I agree, it makes sense.
To elaborate a little more on the idea, I would fetch credentials from environment variables like: DB_USERNAME and DB_PASSWORD maybe.
But that would cause a configuration overhead most likely, I've done a simple createdb command in my manage.py ;).
By the way, thanks for all the Flask tutorials, extensions, etc you work on! They are great, keep up the good work!
I have added a command called create_db to my app that takes a SQLAlchemy URI as an argument. Could something like this could be added to Flask-Migrate?
I have answered why this is not easily done above.
Most helpful comment
As a high level request I understand it can be useful, but I think it is complicated to have a practical implementation of this, simply because the database credentials that the application uses are usually not powerful enough to create databases. At least they shouldn't be, if you follow security best practices.
Creating/destroying databases is a task typically performed by an administrator. The credentials that the application are given are (or should be) restricted to operating on a single existing database, without the ability to create/destroy/read/write any other databases, or manage users, permissions, etc.