Skip to content

Commit 1c69fbb

Browse files
committed
Add 'add_modified_columns' macro for tracking changes
This commit introduces a new PostgreSQL macro, `add_modified_columns`, to simplify the addition of columns for tracking modifications (`modified_user` and `modified_at`). It also includes a trigger function to automatically update the `modified_at` timestamp on changes, enhancing consistency and reducing manual updates. The documentation is updated to demonstrate usage.
1 parent e397d03 commit 1c69fbb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

postgres/ddl-macros.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DDL Postgres Macros
22

3-
In postgres you may find yourself repeating common operations on all your tables. For example adding an audit log ,created times, modified user etc.
3+
In postgres you may find yourself repeating common operations on all your tables. For example adding an [audit log](https://github.com/WHauser-HP/postgres_audit), created times, modified user etc.
44

55
This can be tedious to add everywhere. Instead, you can create a postgres "macro" to update your DDL for you
66

@@ -90,3 +90,5 @@ SELECT public.add_modified_columns('public.orders'),
9090
```
9191

9292
This will modify the specified table by adding the `modified_user` and `modified_at` columns.
93+
94+

0 commit comments

Comments
 (0)