cancel
Showing results for 
Search instead for 
Did you mean: 

CDS deploy- Any change in database, existing data deleted and it seeds non-existing csv file data.

nkaur1311
Explorer

Hello Experts,

I am working on a CAP based Programming model wherein I have defined few entities in data-model.cds in db folder as below

Now the problem is that whenever I make any changes in any of the fields for defined entities and deploy mta.yml file, it always defaults the data in those entities from those csv files, which was once added for testing purposes and deleted later on.

Although I have explored SAP note 2922271 and following steps have been mentioned:

  • Delete the <mytable>.hdbtabledata and associated <mydata>.csv with the predelivered data from your project's files
  • Add the path of the <mytable>.hdbtabledata to the DB module's undeploy.json file, which confirms for deployments to production systems that the .hdbtabledata can really be deleted
  • Extend the command line for hdideploy.js in the DB module's package.json to specify the undeploy of the .hdbtabledata together with the skip_data_deletion parameter:

"start": "node node_modules/@sap/hdi-deploy/deploy.js --undeploy src/<mytable>.hdbtabledata --path-parameter src/<mytable>.hdbtabledata:skip_data_deletion=true"

  • If multiple .hdbtabledata artifacts need to be deleted, add them all to the undeploy.json file and specify them all as part of a single --path-parameter parameter: --path-parameter <path-to-first-hdbtabledata-artifact>:skip_data_deletion=true <path-to-second-hdbtabledata-artifact>:skip_data_deletion=true <path-to-third-hdbtabledata-artifact>:skip_data_deletion=true
  • Deploy the project to the target system
  • Check the build log for information that it kept the existing data for the affected table
  • Restore the previous version of DB module's package.json before any further deployments

Now, my question is where to add undeploy.json file?

Shall I add it inside db folder? If yes, there is no package.json file in db folder to extend the command line for hdideploy.js.

And, I could only see package.json in gen folder. Do I need to perform all the steps here?

Please provide your inputs as this deployment has become a huge issue for us.

Thanks and Regards,

Navneet Kaur.

View Entire Topic

Hi Navneet,

I had the same issue at one point. All I needed was the undeploy.json file which I placed in the root of the db folder.

I included the path to both the csv files and the hdbtabledata files to clear them.

I typically upload my CSV files through the hana database explorer when setting up my seed data.

nkaur1311
Explorer
0 Kudos

Hi Gavin,

Thanks for your input. I tried putting undeploy.json in the root of db folder as below:

[
    "my.xxxxxxx.tableName.hdbtabledata",
    "my.xxxxxxx.tableName.csv"
]

Then tried to deploy, it is still erasing all the data and putting the previous data as it was there in tableName.csv. However, it is not existing anymore in data folder.

Is it really required to upload CSV files in HANA DB explorer? Is there not any way that I deploy DB and the already created data remains in the table?

0 Kudos

Hi Navneet,

Just to be sure, is the path you're putting in pointing to the generated files? For example I use a path like:

[
"src/gen/data/tablename.csv",

"src/gen/data/tablename.csv",

]

If you upload the data in db explorer then it will remain there with any future deployments.