MigrationHook
Base class for migration hooks.
Source code in pum/migration_hooks.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
__init__
__init__(type: str | MigrationHookType, file: str | Path | None = None)
Initialize a MigrationHook instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
str
|
The type of the hook (e.g., "pre", "post"). |
required |
file
|
str
|
The file path of the hook. |
None
|
Source code in pum/migration_hooks.py
28 29 30 31 32 33 34 35 36 37 |
|
execute_sql
execute_sql(conn: Connection, dir: str | Path = '.', commit: bool = False, parameters: dict | None = None)
Execute the SQL file associated with the migration hook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conn
|
Connection
|
The database connection. |
required |
commit
|
bool
|
Whether to commit the transaction after executing the SQL. |
False
|
dir
|
str | Path
|
The root directory of the project. |
'.'
|
parameters
|
dict
|
Parameters to bind to the SQL statement. Defaults to (). |
None
|
Source code in pum/migration_hooks.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|