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
+57-23Lines changed: 57 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,6 @@
2
2
3
3
a [CDS plugin](https://cap.cloud.sap/docs/node.js/cds-plugins#cds-plugin-packages) for automatic capturing, storing, and viewing of the change records of modeled entities
4
4
5
-
6
-
> [!WARNING]
7
-
> Please be aware that [**sensitive** or **personal** data](https://cap.cloud.sap/docs/guides/data-privacy/annotations#annotating-personal-data) should not be change tracked, since viewing the log allows users to circumvent [audit-logging](https://cap.cloud.sap/docs/guides/data-privacy/audit-logging#setup).
-[Disable Association to Changes Generation](#disable-association-to-changes-generation)
21
19
-[Examples](#examples)
22
20
-[Specify Object ID](#specify-object-id)
23
21
-[Tracing Changes](#tracing-changes)
24
-
-[Don'ts](#donts)
22
+
-[Don'ts](#donts)
25
23
-[Contributing](#contributing)
26
24
-[Code of Conduct](#code-of-conduct)
27
25
-[Licensing](#licensing)
@@ -38,6 +36,7 @@ In this guide, we use the [Incidents Management reference sample app](https://gi
38
36
### 1. Prerequisites
39
37
40
38
Clone the repository and apply the step-by-step instructions:
39
+
41
40
```sh
42
41
git clone https://github.com/cap-js/incidents-app
43
42
cd incidents-app
@@ -94,15 +93,17 @@ Additional identifiers or labels can be added to obtain more *human-readable* ch
94
93
With the steps above, we have successfully set up change tracking for our reference application. Let's see that in action.
95
94
96
95
1.**Start the server**:
97
-
```sh
98
-
cds watch
99
-
```
96
+
97
+
```sh
98
+
cds watch
99
+
```
100
+
100
101
2.**Make a change** on your change-tracked elements. This change will automatically be persisted in the database table (`sap.changelog.ChangeLog`) and made available in a pre-defined view, namely the [Change History view](#change-history-view) for your convenience.
101
102
102
103
#### Change History View
103
104
104
105
> [!IMPORTANT]
105
-
> To ensure proper lazy loading of the Change History table, please use **SAPUI5 version 1.120.0** or higher.<br>
106
+
> To ensure proper lazy loading of the Change History table, please use **SAPUI5 version 1.120.0** or higher.`<br>`
106
107
> If you wish to *disable* this feature, please see the customization section on how to [disable lazy loading](#disable-lazy-loading).
The system now uses the SAPUI5 default setting `![@UI.PartOfPreview]: true`, such that the table will always shown when navigating to that respective Object page.
217
218
219
+
### Disable UI Facet generation
220
+
221
+
If you do not want the UI facet added to a specific UI, you can annotate the service entity with `@changelog.disable_facet`. This will disable the automatic addition of the UI faced to this specific entity, but also all views or further projections up the chain.
222
+
223
+
### Disable Association to Changes Generation
224
+
225
+
For some scenarios, e.g. when doing `UNION` and the `@changelog` annotion is still propageted, the automatic addition of the association to `changes` does not make sense. You can use `@changelog.disable_assoc`for this to be disabled on entity level.
226
+
227
+
> [!IMPORTANT]
228
+
> This will also supress the addition of the UI facet, since the change-view is not available as target entity anymore.
229
+
230
+
### Preserve change logs of deleted data
231
+
232
+
By default, deleting a record will also automatically delete all associated change logs. This helps reduce the impact on the size of the database.
233
+
You can turn this behavior off globally by adding the following switch to the `package.json` of your project
234
+
235
+
```
236
+
...
237
+
"cds": {
238
+
"requires": {
239
+
...
240
+
"change-tracking": {
241
+
"preserveDeletes": true
242
+
}
243
+
...
244
+
}
245
+
}
246
+
...
247
+
```
248
+
> [!IMPORTANT]
249
+
> Preserving the change logs of deleted data can have a significant impact on the size of the change logging table, since now such data also survives automated data retention runs.
250
+
> You must implement an own **data retention strategy** for the change logging table in order to manage the size and performance of your database.
251
+
218
252
## Examples
219
253
220
254
This section describes modelling cases for further reference, from simple to complex, including the following:
221
255
222
-
-[Specify Object ID](#specify-object-id)
223
-
-[Use Case 1: Annotate single field/multiple fields of associated table(s) as the Object ID](#use-case-1-annotate-single-fieldmultiple-fields-of-associated-tables-as-the-object-id)
224
-
-[Use Case 2: Annotate single field/multiple fields of project customized types as the Object ID](#use-case-2-annotate-single-fieldmultiple-fields-of-project-customized-types-as-the-object-id)
225
-
-[Use Case 3: Annotate chained associated entities from the current entity as the Object ID](#use-case-3-annotate-chained-associated-entities-from-the-current-entity-as-the-object-id)
226
-
-[Tracing Changes](#tracing-changes)
227
-
-[Use Case 1: Trace the changes of child nodes from the current entity and display the meaningful data from child nodes (composition relation)](#use-case-1-trace-the-changes-of-child-nodes-from-the-current-entity-and-display-the-meaningful-data-from-child-nodes-composition-relation)
228
-
-[Use Case 2: Trace the changes of associated entities from the current entity and display the meaningful data from associated entities (association relation)](#use-case-2-trace-the-changes-of-associated-entities-from-the-current-entity-and-display-the-meaningful-data-from-associated-entities-association-relation)
229
-
-[Use Case 3: Trace the changes of fields defined by project customized types and display the meaningful data](#use-case-3-trace-the-changes-of-fields-defined-by-project-customized-types-and-display-the-meaningful-data)
230
-
-[Use Case 4: Trace the changes of chained associated entities from the current entity and display the meaningful data from associated entities (association relation)](#use-case-4-trace-the-changes-of-chained-associated-entities-from-the-current-entity-and-display-the-meaningful-data-from-associated-entities-association-relation)
231
-
-[Use Case 5: Trace the changes of union entity and display the meaningful data](#use-case-5-trace-the-changes-of-union-entity-and-display-the-meaningful-data)
232
-
-[Don'ts](#donts)
233
-
-[Use Case 1: Don't trace changes for field(s) with `Association to many`](#use-case-1-dont-trace-changes-for-fields-with-association-to-many)
234
-
-[Use Case 2: Don't trace changes for field(s) with *Unmanaged Association*](#use-case-2-dont-trace-changes-for-fields-with-unmanaged-association)
235
-
-[Use Case 3: Don't trace changes for CUD on DB entity](#use-case-3-dont-trace-changes-for-cud-on-db-entity)
256
+
-[Specify Object ID](#specify-object-id)
257
+
-[Use Case 1: Annotate single field/multiple fields of associated table(s) as the Object ID](#use-case-1-annotate-single-fieldmultiple-fields-of-associated-tables-as-the-object-id)
258
+
-[Use Case 2: Annotate single field/multiple fields of project customized types as the Object ID](#use-case-2-annotate-single-fieldmultiple-fields-of-project-customized-types-as-the-object-id)
259
+
-[Use Case 3: Annotate chained associated entities from the current entity as the Object ID](#use-case-3-annotate-chained-associated-entities-from-the-current-entity-as-the-object-id)
260
+
-[Tracing Changes](#tracing-changes)
261
+
-[Use Case 1: Trace the changes of child nodes from the current entity and display the meaningful data from child nodes (composition relation)](#use-case-1-trace-the-changes-of-child-nodes-from-the-current-entity-and-display-the-meaningful-data-from-child-nodes-composition-relation)
262
+
-[Use Case 2: Trace the changes of associated entities from the current entity and display the meaningful data from associated entities (association relation)](#use-case-2-trace-the-changes-of-associated-entities-from-the-current-entity-and-display-the-meaningful-data-from-associated-entities-association-relation)
263
+
-[Use Case 3: Trace the changes of fields defined by project customized types and display the meaningful data](#use-case-3-trace-the-changes-of-fields-defined-by-project-customized-types-and-display-the-meaningful-data)
264
+
-[Use Case 4: Trace the changes of chained associated entities from the current entity and display the meaningful data from associated entities (association relation)](#use-case-4-trace-the-changes-of-chained-associated-entities-from-the-current-entity-and-display-the-meaningful-data-from-associated-entities-association-relation)
265
+
-[Use Case 5: Trace the changes of union entity and display the meaningful data](#use-case-5-trace-the-changes-of-union-entity-and-display-the-meaningful-data)
266
+
-[Don'ts](#donts)
267
+
-[Use Case 1: Don't trace changes for field(s) with `Association to many`](#use-case-1-dont-trace-changes-for-fields-with-association-to-many)
268
+
-[Use Case 2: Don't trace changes for field(s) with *Unmanaged Association*](#use-case-2-dont-trace-changes-for-fields-with-unmanaged-association)
269
+
-[Use Case 3: Don't trace changes for CUD on DB entity](#use-case-3-dont-trace-changes-for-cud-on-db-entity)
0 commit comments