-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from JoshYuJump/main
Integrated FastAPI-Migrate ref issue #150
- Loading branch information
Showing
15 changed files
with
162 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,3 +135,4 @@ dmypy.json | |
# test and example sqlite db file | ||
tests/test.db | ||
examples/**/*.sqlite | ||
examples/**/migrations |
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
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,41 @@ | ||
import typer | ||
|
||
typer_app = typer.Typer() | ||
|
||
|
||
def callback(): | ||
""" | ||
Bali App entry 4.0 style | ||
""" | ||
|
||
|
||
def entry(application): | ||
"""Bali application CLI entry | ||
""" | ||
|
||
# When migrate enabled, cli group will changed | ||
# in <4.0, ENABLE_MIGRATE default is `False` | ||
# in >=4.0, ENABLE_MIGRATE default is `True` | ||
# | ||
# migrate disabled: cli used as same as bali < 4.0 | ||
# eg: python main.py --http | ||
# migrate enabled: cli used as same as bali >= 4.0 | ||
# eg: bali run http | ||
try: | ||
from config import settings | ||
enable_migrate = settings.ENABLE_MIGRATE | ||
except: | ||
enable_migrate = False | ||
|
||
if enable_migrate: | ||
typer_app.command()(application.launch) | ||
typer_app.callback()(callback) | ||
|
||
from fastapi_migrate.cli import db | ||
typer_click_object = typer.main.get_command(typer_app) | ||
typer_click_object.add_command(db, "db") | ||
|
||
typer_click_object() | ||
else: | ||
typer_app.command()(application.launch) | ||
typer_app() |
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,20 @@ | ||
# config | ||
|
||
## configuration file | ||
|
||
Configuration file is a python file location in project root directory. | ||
|
||
```bash | ||
todos | ||
├── README.md | ||
├── client.py | ||
├── config.py <-- configuration file | ||
├── main.py | ||
├── migrations | ||
├── models.py | ||
├── protos | ||
├── resources.py | ||
└── todo.sqlite | ||
``` | ||
|
||
Todos Example project configuration file: [config.py](examples/todos/config.py) |
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 @@ | ||
# Quick Start |
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 @@ | ||
# Quick Start |
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
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