Skip to content

Commit d3e2dfe

Browse files
committed
further rename
1 parent c23ba78 commit d3e2dfe

File tree

9 files changed

+37
-29
lines changed

9 files changed

+37
-29
lines changed

BACKWARD_COMPATIBILITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PUM now supports reading legacy `.pum.yaml` files that use the old field names `
88

99
The refactoring renamed hook-related fields for better clarity:
1010
- **Old**: `migration_hooks` with `pre`/`post` hooks
11-
- **New**: `application_hooks` with `drop`/`create` hooks
11+
- **New**: `application` with `drop`/`create` hooks
1212

1313
## Future Considerations
1414

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PUM (PostgreSQL Upgrades Manager) is a robust database migration management tool
1616
- **Command-line and Python Integration**: Use PUM as a standalone CLI tool or integrate it into your Python project.
1717
- **Database Versioning**: Automatically manage database versioning with a metadata table.
1818
- **Changelog Management**: Apply and track SQL delta files for database upgrades.
19-
- **Migration Hooks**: Define custom hooks to execute additional SQL or Python code to drop or create the application schema during migrations. This feature allows you to isolate data (table) code from application code (such as views and triggers), ensuring a clear separation of concerns and more maintainable database structures.
19+
- **Migration Hooks**: Define custom hooks to execute additional SQL or Python code to drop or create the application during migrations. This feature allows you to isolate data (table) code from application code (such as views and triggers), ensuring a clear separation of concerns and more maintainable database structures.
2020

2121
## Why PUM?
2222

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
# Migration hooks
1+
# Application
22

3-
Migration hooks allow you to define actions to be executed during the migration process. These hooks are defined in the `.pum.yaml` configuration file under the `application_hooks` section.
3+
## Application/data isolation
4+
5+
Separating application logic from object (business) data is recommended. Place application-owned objects—such as views, functions, procedures, and triggers—into dedicated, application-specific schemas, while keeping persistent business tables in one or several separate data schemas.
6+
7+
This isolation makes application artifacts clearly distinct from long-lived data, so application schemas can be dropped and recreated on demand (for rebuilds, upgrades, or environment resets) without impacting the underlying object data.
8+
9+
Application hooks allow you to define actions to be executed during the migration process.
10+
They allow the creation and removal of the application part of the data model.
11+
These hooks are defined in the `.pum.yaml` configuration file under the `application` section.
412

513
There are two types of migration hooks:
614

7-
- `drop`: Hooks to drop the application schema before applying migrations.
8-
- `create`: Hooks to create the application schema after applying migrations.
15+
- `drop`: Hooks to drop the application before applying migrations.
16+
- `create`: Hooks to create the application after applying migrations.
917

1018
## SQL hooks
1119

1220
Hooks are defined as a list of files or plain SQL code to be executed. For example:
1321

1422
```yaml
15-
application_hooks:
23+
application:
1624
drop:
1725
- code: DROP VIEW IF EXISTS pum_test_app.some_view;
1826

@@ -32,7 +40,7 @@ You can use `pum.utils.execute_sql` to execute the SQL code without committing.
3240
The configuration is then:
3341

3442
```yaml
35-
application_hooks:
43+
application:
3644
drop:
3745
- file: drop_app/drop_view.sql
3846

docs/docs/configuration/application_hooks_model.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ApplicationModel
2+
3+
::: pum.config_model.ApplicationModel

docs/docs/configuration/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In the config file `.pum.yaml`, you can define, with the YAML syntax:
66

77
* `changelogs_directory`: the directory with the changelogs files.
88
* `parameters`: the definition of parameters for the migration.
9-
* `application_hooks`: the `drop` and `create` application schema hooks.
9+
* `application`: the `drop` and `create` application hooks.
1010

1111
For example:
1212
```yaml

docs/mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ nav:
7272
- ConfigModel: configuration/config_model.md
7373
- DependencyModel: configuration/dependency_model.md
7474
- HookModel: configuration/hook_model.md
75-
- ApplicationHookModel: configuration/application_hooks_model.md
75+
- ApplicationModel: configuration/application_model.md
7676
- ParameterDefinitionModel: configuration/parameter_definition_model.md
7777
- PermissionModel: configuration/permission_model.md
7878
- PumModel: configuration/pum_model.md
7979
- RoleModel: configuration/role_model.md
8080

81-
- Hooks: hooks.md
81+
- Application: application.md
8282
- Roles: roles.md
8383
- CLI:
8484
- Overview: cli.md

pum/config_model.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ def validate_args(self):
5454
return self
5555

5656

57-
class ApplicationHookModel(PumCustomBaseModel):
57+
class ApplicationModel(PumCustomBaseModel):
5858
"""
59-
ApplicationHookModel holds the configuration for application schema hooks.
59+
ApplicationModel holds the configuration for application hooks.
6060
6161
Attributes:
62-
drop: Hooks to drop the application schema before applying migrations.
63-
create: Hooks to create the application schema after applying migrations.
62+
drop: Hooks to drop the application before applying migrations.
63+
create: Hooks to create the application after applying migrations.
6464
"""
6565

6666
drop: Optional[List[HookModel]] = Field(default=[], alias="pre")
@@ -197,15 +197,15 @@ class ConfigModel(PumCustomBaseModel):
197197
Attributes:
198198
pum: The PUM (Project Update Manager) configuration. Defaults to a new PumModel instance.
199199
parameters: List of parameter definitions. Defaults to an empty list.
200-
application_hooks: Configuration for application schema hooks. Defaults to a new ApplicationHookModel instance.
200+
application: Configuration for application hooks. Defaults to a new ApplicationModel instance.
201201
changelogs_directory: Directory path for changelogs. Defaults to "changelogs".
202202
roles: List of role definitions. Defaults to None.
203203
"""
204204

205205
pum: Optional[PumModel] = Field(default_factory=PumModel)
206206
parameters: Optional[List[ParameterDefinitionModel]] = []
207-
application_hooks: Optional[ApplicationHookModel] = Field(
208-
default_factory=ApplicationHookModel, alias="migration_hooks"
207+
application: Optional[ApplicationModel] = Field(
208+
default_factory=ApplicationModel, alias="migration_hooks"
209209
)
210210
changelogs_directory: Optional[str] = "changelogs"
211211
roles: Optional[List[RoleModel]] = []
@@ -216,6 +216,6 @@ class ConfigModel(PumCustomBaseModel):
216216
def handle_legacy_field_names(cls, values):
217217
"""Support legacy field names for backward compatibility."""
218218
# If new name doesn't exist but old name does, use old name
219-
if "application_hooks" not in values and "migration_hooks" in values:
220-
values["application_hooks"] = values.pop("migration_hooks")
219+
if "application" not in values and "migration_hooks" in values:
220+
values["application"] = values.pop("migration_hooks")
221221
return values

pum/pum_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ def drop_app_handlers(self) -> list[HookHandler]:
250250
return (
251251
[
252252
HookHandler(base_path=self._base_path, **hook.model_dump())
253-
for hook in self.config.application_hooks.drop
253+
for hook in self.config.application.drop
254254
]
255-
if self.config.application_hooks.drop
255+
if self.config.application.drop
256256
else []
257257
)
258258

@@ -261,9 +261,9 @@ def create_app_handlers(self) -> list[HookHandler]:
261261
return (
262262
[
263263
HookHandler(base_path=self._base_path, **hook.model_dump())
264-
for hook in self.config.application_hooks.create
264+
for hook in self.config.application.create
265265
]
266-
if self.config.application_hooks.create
266+
if self.config.application.create
267267
else []
268268
)
269269

@@ -311,9 +311,9 @@ def validate(self, install_dependencies: bool = False) -> None:
311311
raise PumInvalidChangelog(f"Changelog `{changelog}` is invalid.") from e
312312

313313
hook_handlers = []
314-
if self.config.application_hooks.drop:
314+
if self.config.application.drop:
315315
hook_handlers.extend(self.drop_app_handlers())
316-
if self.config.application_hooks.create:
316+
if self.config.application.create:
317317
hook_handlers.extend(self.create_app_handlers())
318318
for hook_handler in hook_handlers:
319319
try:

0 commit comments

Comments
 (0)