You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ PUM (PostgreSQL Upgrades Manager) is a robust database migration management tool
16
16
-**Command-line and Python Integration**: Use PUM as a standalone CLI tool or integrate it into your Python project.
17
17
-**Database Versioning**: Automatically manage database versioning with a metadata table.
18
18
-**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.
Copy file name to clipboardExpand all lines: docs/docs/application.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,26 @@
1
-
# Migration hooks
1
+
# Application
2
2
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.
4
12
5
13
There are two types of migration hooks:
6
14
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.
9
17
10
18
## SQL hooks
11
19
12
20
Hooks are defined as a list of files or plain SQL code to be executed. For example:
13
21
14
22
```yaml
15
-
application_hooks:
23
+
application:
16
24
drop:
17
25
- code: DROP VIEW IF EXISTS pum_test_app.some_view;
18
26
@@ -32,7 +40,7 @@ You can use `pum.utils.execute_sql` to execute the SQL code without committing.
0 commit comments