-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add mara_db click group * update docs * typo
- Loading branch information
1 parent
ae69f7b
commit 3ea3111
Showing
5 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CLI | ||
=== | ||
|
||
.. module:: mara_db.cli | ||
|
||
This part of the documentation covers all the available cli commands of Mara DB. | ||
|
||
|
||
``migrate`` | ||
----------- | ||
|
||
.. tabs:: | ||
|
||
.. group-tab:: Mara CLI | ||
|
||
.. code-block:: shell | ||
mara db migrate | ||
.. group-tab:: Mara Flask App | ||
|
||
.. code-block:: python | ||
flask mara-db migrate | ||
Compares the current database db alias `mara` with all defined models and applies | ||
the diff using alembic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
"""Auto-migrate command line interface""" | ||
|
||
import click | ||
import sys | ||
from warnings import warn | ||
|
||
import click | ||
|
||
@click.group() | ||
def mara_db(): | ||
"""Commands to interact with the database.""" | ||
pass | ||
|
||
@click.command() | ||
|
||
@mara_db.command() | ||
def migrate(): | ||
"""Compares the current database with all defined models and applies the diff""" | ||
import mara_db.auto_migration | ||
|
||
if not mara_db.auto_migration.auto_discover_models_and_migrate(): | ||
sys.exit(-1) | ||
|
||
|
||
# Old cli commands to be dropped in 5.0: | ||
|
||
@click.command("migrate") | ||
def _migrate(): | ||
"""Compares the current database with all defined models and applies the diff""" | ||
warn("CLI command `<app> mara_db.migrate` will be dropped in 5.0. Please use: `<app> mara-db migrate`") | ||
migrate.callback() |