[cli] Added install command to install the database and all plugins
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
This commit is contained in:
parent
6c73a63eb5
commit
74ceb1b1f3
|
@ -50,10 +50,16 @@ If not you need to create user and database manually do (or similar on Windows):
|
||||||
) | sudo mysql
|
) | sudo mysql
|
||||||
|
|
||||||
Then you can install the database tables, this will update all tables from core + all enabled plugins.
|
Then you can install the database tables, this will update all tables from core + all enabled plugins.
|
||||||
*Hint:* The same command can be later used to upgrade the database after plugins or core are updated.
|
And also install all enabled plugins:
|
||||||
|
|
||||||
|
$ flaschengeist install
|
||||||
|
|
||||||
|
*Hint:* To only install the database tables, or upgrade the database after plugins or core are updated later
|
||||||
|
you can use this command:
|
||||||
|
|
||||||
$ flaschengeist db upgrade heads
|
$ flaschengeist db upgrade heads
|
||||||
|
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
To only upgrade one plugin (for example the `events` plugin):
|
To only upgrade one plugin (for example the `events` plugin):
|
||||||
|
|
||||||
|
@ -88,6 +94,7 @@ with the difference of the main logger will be forced to output to `stderr` and
|
||||||
of the CLI will override the logging level you have configured for the main logger.
|
of the CLI will override the logging level you have configured for the main logger.
|
||||||
|
|
||||||
$ flaschengeist run
|
$ flaschengeist run
|
||||||
|
|
||||||
or with debug messages:
|
or with debug messages:
|
||||||
|
|
||||||
$ flaschengeist run --debug
|
$ flaschengeist run --debug
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
alembic_migrations = str(Path(__file__).resolve().parent / "migrations")
|
|
@ -88,12 +88,14 @@ def main(*args, **kwargs):
|
||||||
from .export_cmd import export
|
from .export_cmd import export
|
||||||
from .docs_cmd import docs
|
from .docs_cmd import docs
|
||||||
from .run_cmd import run
|
from .run_cmd import run
|
||||||
|
from .install_cmd import install
|
||||||
|
|
||||||
# Override logging level
|
# Override logging level
|
||||||
environ.setdefault("FG_LOGGING", logging.getLevelName(LOGGING_MAX))
|
environ.setdefault("FG_LOGGING", logging.getLevelName(LOGGING_MAX))
|
||||||
|
|
||||||
cli.add_command(export)
|
cli.add_command(export)
|
||||||
cli.add_command(docs)
|
cli.add_command(docs)
|
||||||
|
cli.add_command(install)
|
||||||
cli.add_command(plugin)
|
cli.add_command(plugin)
|
||||||
cli.add_command(run)
|
cli.add_command(run)
|
||||||
cli(*args, **kwargs)
|
cli(*args, **kwargs)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import click
|
||||||
|
from click.decorators import pass_context
|
||||||
|
from flask.cli import with_appcontext
|
||||||
|
from flask_migrate import upgrade
|
||||||
|
|
||||||
|
from flaschengeist.alembic import alembic_migrations
|
||||||
|
from flaschengeist.cli.plugin_cmd import install_plugin_command
|
||||||
|
from flaschengeist.utils.hook import Hook
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@with_appcontext
|
||||||
|
@pass_context
|
||||||
|
@Hook("plugins.installed")
|
||||||
|
def install(ctx):
|
||||||
|
# Install database
|
||||||
|
upgrade(alembic_migrations, revision="heads")
|
||||||
|
|
||||||
|
# Install plugins
|
||||||
|
install_plugin_command(ctx, [], True)
|
Loading…
Reference in New Issue