harp_apps.storage.utils.migrations

Inheritance diagram of harp_apps.storage.utils.migrations

exception StorageBootError[source]

Bases: RuntimeError

A storage failure whose message is the password-masked rendering of the original failure chain.

create_alembic_config(url)[source]

Create our alembic configuration object, to run alembic commands.

Parameters:

url (str | URL | Url | MultiHostUrl)

create_harp_settings_with_storage_from_command_line_options(kwargs)[source]

Create a Harp configuration object using common server command line options (–set…) with the sqlalchemy storage application installed so that the storage is properly configured.

async do_migrate(engine, *, migrator, reset=False)[source]
async do_reset(engine)[source]
async ensure_schema_is_current(engine)[source]

Raise OutdatedSchemaError if the database schema is older than what this code expects.

SQLite schemas are created without alembic, so they are compared to the models. Other databases are compared to the latest alembic revision.

hide_password(message, url)[source]

Mask the password of url where it sits in a url in message: its userinfo or ?password=.

The shared shape-based masking runs on top, so any other url is covered whatever its encoding. Elsewhere the password is left alone: it is often a common word, or the user or database name, and masking it there would corrupt the message.

Parameters:
  • message (str)

  • url (str | URL | Url | MultiHostUrl)

Return type:

str

mask_failure(exc, url)[source]

Return exc itself when its rendering holds no password, else a StorageBootError that replaces it.

Parameters:
Return type:

BaseException

printable_url(url)[source]

Render url for a message, its password masked wherever the url holds it.

Parameters:

url (str | URL | Url | MultiHostUrl)

Return type:

str

render_failure(exc, url)[source]

Render exc and its whole cause chain (any attribute str() uses), password masked.

Parameters:
Return type:

str