cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CSV file, ignore while deploying to production

NitinMahajan
Product and Topic Expert
Product and Topic Expert
4,365

Hi ,

I am using CAP for build an application on HANA Cloud. I have used CSV file to do some testing. However, while deploying to production, i want to ignore those files?

Is it possible by some configuration (for example in Package.json)?

Regards,

nitin

Accepted Solutions (1)

Accepted Solutions (1)

lothar_bender
Product and Topic Expert
Product and Topic Expert

The better solution might be to move the CSV files containing test data to the folder test/data.
cds watch is loading CSV files contained in the test folder by default while cds watch --production does not. Same holds true for production build and deployments, e.g. cds build --production, cds deploy --to hana --production.

Make sure that CSV files intended for testing aren't deployed to production by mistake as this would impact subsequent HANA deployments.

See also [providing initial data](https://cap.cloud.sap/docs/guides/databases#providing-initial-data).

Anton_Mavrin1
Product and Topic Expert
Product and Topic Expert
0 Likes

Sounds like a great solution 🙂

AlessandroSpadoni
Contributor
0 Likes

Hi Lothar,

in my opinion this is the best approach to have a local environment with data with no risk to deploying csv in production,

I didn't find anything in cap.cloud.sap , do you know how to find additional documentation about it? by the way I already tried and it works like a charm

Thanks

lothar_bender
Product and Topic Expert
Product and Topic Expert
0 Likes
This approach isn't documented yet, but we will integrate it as part of some other changes related to the "handling initial test data topic"
dmalav
Associate
Associate
0 Likes

I apologise for multiple comments, happened due to a misunderstanding

dmalav
Associate
Associate
0 Likes
Hi Lothar, I am also trying to do this, and came across your comment here. The csv files in test/data do not load for me when I run the application locally. To be more precise: I created this test/data folder at the same level as the db folder. I am confused as to what I am missing, even after going through the documentation. Could you help me understand what I could be missing?
dmalav
Associate
Associate
0 Likes
Hi Nithin, I am also trying to do this, and came across your comment here. I see that you were able to make this work! For me, the csv files in test/data do not load when I run the application locally. To be more precise: I created this test/data folder at the same level as the db folder. I am confused as to what I am missing, even after going through the documentation. Could you help me understand what I could be missing?
lothar_bender
Product and Topic Expert
Product and Topic Expert
0 Likes
Are you using cds watch?
lothar_bender
Product and Topic Expert
Product and Topic Expert
0 Likes
The filenames are expected to match fully qualified names of respective entity definitions in your CDS models, optionally using a dash - instead of a dot . for cosmetic reasons.

Answers (2)

Answers (2)

Epena
Participant

Hello,

From SAP tutorial Deploy Your Multi-Target Application (MTA), specifically section Exclude CSV files from deployment:

You change the MTA build parameters to:

  • install all the dependencies with production profiles.
  • remove all the DB data (CSV files and the hdbtabledata) that is generated by the CAP server out of the CSV files.

Add the following line to the mta.yaml file:

build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p @sap/cds-dk cds build --production
- npx rimraf gen/db/src/gen/data

Regards.

lothar_bender
Product and Topic Expert
Product and Topic Expert
0 Likes

Thanks for the hint - I will check...

Epena
Participant

Hello lothar.bender,

I'm not sure I see the inconsistency. In the link you provided, they talk about providing initial data, but they add a disclaimer:

On SAP HANA, only use CSV files for configuration data that can’t be changed by application users. CSV files are deployed as .hdbtabledata which assumes exclusive ownership of the data. It’s overwritten with the next application deployment. To avoid such a situation, you can use the include_filter option that .hdbtabledata offers.

Whereas in the tutorial, the initial data is meant to be used while testing locally (sqlite or in-memory), and since they don't want the data in the .csv's to be loaded into Hana upon deploy as that initial data doesn't make sense in the production environment, or it's going to be changed by application users.

Regards.

lothar_bender
Product and Topic Expert
Product and Topic Expert

Thanks for the hint. You are right, we should clearly distinguish the scenarios. When providing initial data for production, certain criteria must be fulfilled as HANA is assuming exclusive ownership of the predefined data. As the name implies, test data must not be deployed to production as this would impact further deployments.
I think the approach of using different CSV locations for both scenarios also fits better in this respect instead of deleting the CSV files later on as described in the tutorial.

I've already updated my initial answer. We will enhance the Capire documentation by a separate topic Providing Test Data. I will add the link once available.

Regards

marcmaur
Participant

Hi Nitin,

I don't know if our solution is the best one (wait for other answers before accepting this one 🙂 ), but we solve it by adding the following lines in the mta.yaml:

The first one applies to single-tenant applications, while the second one is required for multi-tenant applications.

Best regards,

Marc