From bb79d5db2a370f2fe56ba163067f5aa19621ad6e Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 12 Nov 2024 13:09:27 -0800 Subject: [PATCH] Fix Alembic documentation Fix incorrect code highlighting, some missing code in the examples, and some missing details about the tox setup. --- docs/user-guide/database/schema.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/database/schema.rst b/docs/user-guide/database/schema.rst index 0995434b..024c6f33 100644 --- a/docs/user-guide/database/schema.rst +++ b/docs/user-guide/database/schema.rst @@ -221,6 +221,13 @@ Here is one way to implement that: @main.command() + @click.option( + "--alembic-config-path", + envvar="EXAMPLE_ALEMBIC_CONFIG_PATH", + type=click.Path(path_type=Path), + default=Path("/app/alembic.ini"), + help="Alembic configuration file.", + ) @run_with_asyncio async def validate_schema(*, alembic_config_path: Path) -> None: """Validate that the database schema is current.""" @@ -243,7 +250,7 @@ Delete any line like that. Then, in :file:`main.py`, add code to check the database schema in the application's lifespan hook before initializing the database session dependency. .. code-block:: python - :emphasize-lines: 4,5,14-20 + :emphasize-lines: 6-7,14-20 from collections.abc import AsyncIterator from contextlib import asynccontextmanager @@ -360,6 +367,7 @@ In :ref:`database-alembic-config`, you created an ``alembic`` tox environment. Add the environment variable settings to that environment that tell your application to use the PostgreSQL instance started by :command:`docker-compose`: .. code-block:: toml + :emphasize-lines: 5-7 :force: [testenv:alembic] @@ -372,7 +380,7 @@ Add the environment variable settings to that environment that tell your applica Change the database name, username, and environment variable prefix to match your application. -You will also need a tox environment that runs your application. +You will also need a tox environment that runs your application's command-line interface. This will look something like the following: .. code-block:: toml