Skip to content

HookModel

Bases: PumCustomBaseModel

HookModel represents a migration hook configuration.

Attributes:

Name Type Description
file Optional[str]

Optional path to a SQL file to execute as a hook.

code Optional[str]

Optional Python code to execute as a hook.

Source code in pum/config_model.py
class HookModel(PumCustomBaseModel):
    """
    HookModel represents a migration hook configuration.

    Attributes:
        file: Optional path to a SQL file to execute as a hook.
        code: Optional Python code to execute as a hook.
    """

    file: Optional[str] = None
    code: Optional[str] = None

    @model_validator(mode="after")
    def validate_args(self):
        file, code = self.file, self.code
        if (file and code) or (not file and not code):
            raise PumConfigError("Exactly one of 'file' or 'code' must be set in a hook.")
        return self