File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 44
55### 0.2.0
66
7+ - feat: generate schemas optionally ([ #7 ] )
78- Use ` asyncclick ` instead of ` click ` ([ #6 ] )
89- Only install tomlkit for Python version less than 3.11 ([ #5 ] )
910- Migrate lint tool from isort+black to ruff ([ #5 ] )
1011- Drop support for Python3.8 ([ #4 ] )
1112
13+ [ #7 ] : https://github.com/tortoise/tortoise-cli/pull/7
1214[ #6 ] : https://github.com/tortoise/tortoise-cli/pull/6
1315[ #5 ] : https://github.com/tortoise/tortoise-cli/pull/5
1416[ #4 ] : https://github.com/tortoise/tortoise-cli/pull/4
Original file line number Diff line number Diff line change @@ -27,16 +27,26 @@ async def aclose_tortoise() -> AsyncGenerator[None]:
2727 "--config" ,
2828 help = "TortoiseORM config dictionary path, like settings.TORTOISE_ORM" ,
2929)
30+ @click .option (
31+ "--generate-schemas/--no-generate-schemas" ,
32+ default = None ,
33+ help = "Whether generate schemas after TortoiseORM inited" ,
34+ )
3035@click .pass_context
31- async def cli (ctx : click .Context , config : str | None ) -> None :
36+ async def cli (ctx : click .Context , config : str | None , generate_schemas : bool | None = None ) :
3237 if not config and not (config := utils .tortoise_orm_config ()):
3338 raise click .UsageError (
3439 "You must specify TORTOISE_ORM in option or env, or config file pyproject.toml from config of aerich" ,
3540 ctx = ctx ,
3641 )
3742 tortoise_config = utils .get_tortoise_config (ctx , config )
3843 await Tortoise .init (config = tortoise_config )
39- await Tortoise .generate_schemas (safe = True )
44+ if generate_schemas is None :
45+ cons = tortoise_config ["connections" ]
46+ # Auto generate schemas when flag not explicitly passed and dialect is sqlite
47+ generate_schemas = "sqlite" in str (cons .get ("default" , cons ))
48+ if generate_schemas :
49+ await Tortoise .generate_schemas (safe = True )
4050
4151
4252@cli .command (help = "Start a interactive shell." )
You can’t perform that action at this time.
0 commit comments