MCPcopy Create free account
hub / github.com/dot-agent/nextpy / makemigrations

Function makemigrations

nextpy/cli.py:417–440  ·  view source on GitHub ↗

Create autogenerated alembic migration scripts.

(
    message: str = typer.Option(
        None, help="Human readable identifier for the generated revision."
    ),
)

Source from the content-addressed store, hash-verified

415
416@db_cli.command()
417def 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()

Callers

nothing calls this directly

Calls 3

_skip_compileFunction · 0.85
get_db_engineMethod · 0.80
alembic_autogenerateMethod · 0.80

Tested by

no test coverage detected