@cap-js/change-tracking 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,13 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
6
6
 
7
- ## Version 1.1.5 - TBD
7
+ ## Version 1.2.0 - 25.03.26
8
8
 
9
9
  ### Added
10
-
11
- ### Fixed
12
-
13
- ### Changed
10
+ - Added `createdAt` and `createdBy` columns to Changes table for v2 migration
11
+ - Merge `createdAt` and `createdBy` columns from ChangeLog to Changes in multitenancy scenario
14
12
 
15
13
  ## Version 1.1.4 - 03.12.25
16
14
 
package/cds-plugin.js CHANGED
@@ -247,6 +247,24 @@ function addGenericHandlers() {
247
247
  srv.after('READ', srv.entities.ChangeView, _afterReadChangeView);
248
248
  }
249
249
  }
250
+
251
+ // Add migration handlers for MTX scenario
252
+ const profiles = cds.env.profiles ?? [cds.env.profile]
253
+ const isHana = cds.env.requires?.db?.kind === 'hana';
254
+ if (profiles.includes("mtx-sidecar") && isHana) {
255
+ const { 'cds.xt.DeploymentService': ds } = cds.services
256
+ ds.after('deploy', async (_, req) => {
257
+ const { tenant } = req.data
258
+
259
+ const MERGE_SQL = `MERGE INTO SAP_CHANGELOG_CHANGES AS c USING SAP_CHANGELOG_CHANGELOG AS cl ON c.changeLog_ID = cl.ID
260
+ + WHEN MATCHED THEN UPDATE SET c.createdAt = cl.createdAt, c.createdBy = cl.createdBy`;
261
+
262
+ await cds.tx({ tenant }, async (tx) => {
263
+ await tx.run(MERGE_SQL);
264
+ })
265
+ DEBUG(`Migration: copied createdAt/createdBy from ChangeLog to Changes for tenant: ${tenant}`)
266
+ })
267
+ }
250
268
  }
251
269
  }
252
270
 
package/index.cds CHANGED
@@ -49,6 +49,7 @@ entity ChangeLog : managed, cuid {
49
49
  * Attribute-level Changes with simple capturing of one-level
50
50
  * composition trees in parent... elements.
51
51
  */
52
+ @cds.persistence.journal
52
53
  entity Changes {
53
54
 
54
55
  key ID : UUID @UI.Hidden;
@@ -76,6 +77,8 @@ entity Changes {
76
77
 
77
78
  valueDataType : String(5000) @title: '{i18n>Changes.valueDataType}';
78
79
  changeLog : Association to ChangeLog @title: '{i18n>ChangeLog.ID}' @UI.Hidden;
80
+ createdAt : managed:createdAt @title : '{i18n>ChangeLog.createdAt}';
81
+ createdBy : managed:createdBy @title : '{i18n>ChangeLog.createdBy}';
79
82
  }
80
83
 
81
84
  annotate ChangeView with @(UI: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/change-tracking",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "CDS plugin providing out-of-the box support for automatic capturing, storing, and viewing of the change records of modeled entities.",
5
5
  "repository": "cap-js/change-tracking",
6
6
  "author": "SAP SE (https://www.sap.com)",