Create autogenerated alembic migration scripts.
(
message: str = typer.Option(
None, help="Human readable identifier for the generated revision."
),
)
| 415 | |
| 416 | @db_cli.command() |
| 417 | def makemigrations( |
| 418 | message: str = typer.Option( |
| 419 | None, help="Human readable identifier for the generated revision." |
| 420 | ), |
| 421 | ): |
| 422 | """Create autogenerated alembic migration scripts.""" |
| 423 | from alembic.util.exc import CommandError |
| 424 | |
| 425 | from nextpy.build import prerequisites |
| 426 | from nextpy.data import model |
| 427 | |
| 428 | _skip_compile() |
| 429 | prerequisites.get_compiled_app() |
| 430 | if not prerequisites.check_db_initialized(): |
| 431 | return |
| 432 | with model.Model.get_db_engine().connect() as connection: |
| 433 | try: |
| 434 | model.Model.alembic_autogenerate(connection=connection, message=message) |
| 435 | except CommandError as command_error: |
| 436 | if "Target database is not up to date." not in str(command_error): |
| 437 | raise |
| 438 | console.error( |
| 439 | f"{command_error} Run [bold]nextpy db migrate[/bold] to update database." |
| 440 | ) |
| 441 | |
| 442 | |
| 443 | @cli.command() |
nothing calls this directly
no test coverage detected