@cap-js/change-tracking 1.1.4 → 1.2.1

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,16 @@ 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
8
-
9
- ### Added
7
+ ## Version 1.2.1 - 26.03.26
10
8
 
11
9
  ### Fixed
10
+ - Removed `@cds.persistence.journal` annotation from Changes entity that caused deployment errors
12
11
 
13
- ### Changed
12
+ ## Version 1.2.0 - 25.03.26
13
+
14
+ ### Added
15
+ - Added `createdAt` and `createdBy` columns to Changes table for v2 migration
16
+ - Merge `createdAt` and `createdBy` columns from ChangeLog to Changes in multitenancy scenario
14
17
 
15
18
  ## Version 1.1.4 - 03.12.25
16
19
 
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
@@ -76,6 +76,8 @@ entity Changes {
76
76
 
77
77
  valueDataType : String(5000) @title: '{i18n>Changes.valueDataType}';
78
78
  changeLog : Association to ChangeLog @title: '{i18n>ChangeLog.ID}' @UI.Hidden;
79
+ createdAt : managed:createdAt @title : '{i18n>ChangeLog.createdAt}';
80
+ createdBy : managed:createdBy @title : '{i18n>ChangeLog.createdBy}';
79
81
  }
80
82
 
81
83
  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.1",
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)",