Skip to Content
0
Jul 06, 2020 at 02:41 PM

Database table contents are refreshed with the slightest change in the cds data model

69 Views Last edit Jul 06, 2020 at 11:45 PM 3 rev

I have setup a fairly simple cds models that has a group of master data tables and transactional data tables. I have successfully deployed a fully operational MTA project. Everything is fine, the application is running and I have saved some data using my frontend UI5 application.

Then a situation came where I need to increase the field length of a database field (master data) from 1 to 4 characters. When I deployed my MTA project, I found out that my database table records (transactional data) has been wiped out -- as if i deployed the MTA project for the first time. Below is the description of changes:

context core {
    entity MessageTypes {
        key Id          : String(4); // <--- updated only the string length
            Description : localized type.MediumDescription;
    }
}

The transactional table is not even changed yet the data seems to be refreshed. Is this a bug in the CDS framework? Please advise. Thanks!

UPDATED:

The master data table MessageTypes is linked to the transactional table through Association. Here's the additional information below on the linkage:

context td {
    entity Runs : cuid {
        RunEnd            : Timestamp;
        Duration          : Decimal(13, 2);
        ToLogs            : Association to many Logs
                                on ToLogs.ToRun = $self;
    }

    entity Logs : cuid {
        ToRun                : Association to Runs;
        ToMessageType        : Association to core.MessageTypes;
        virtual ExternalId   : Integer;
        virtual MessageClass : String;
    }
}

UPDATED:

Runs and Logs table doesn't have CSV populated data. Only MessageTypes has -- see below:

Id;Description
S;Success
I;Information
W;Warning
E;Error
A;Abort

Also note that Logs entity is being use as a definition only, it is primarily used as a virtual entity with association to a persistent entity Runs.