Bases: PumCustomBaseModel
HookModel represents a migration hook configuration.
It can either execute a file (SQL or Python script) or run inline SQL code.
Attributes:
| Name |
Type |
Description |
file |
Optional[str]
|
Optional path to a SQL file or a Python script to execute as a hook.
|
code |
Optional[str]
|
Optional SQL code to execute as a hook.
|
Source code in pum/config_model.py
| class HookModel(PumCustomBaseModel):
"""
HookModel represents a migration hook configuration.
It can either execute a file (SQL or Python script) or run inline SQL code.
Attributes:
file: Optional path to a SQL file or a Python script to execute as a hook.
code: Optional SQL 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
|