cds deploy deploys a given model to a database.
The example below deploys models to the sqlite database myWorkOrder in the directory db
cds deploy --to sqlite:db/myWorkOrder
The deployment outputs the following information, indicating the database is filled with the initial data in the csv files locates by convention at db/data. Deployment was successful.
> filling jem.mwo.Interactions from db/data/jem.mwo-Interactions.csv > successfully deployed to ./db/myWorkOrder
Now we have a persistent database and the package.json is updated accordingly.
From time to time, however, I change my mind and I want to update the initial data and revert to working from memory.
I've found that cds deploy to the special database :memory: deploys to sqlite in memory and updates the package.json accordingly.
cds deploy --to sqlite::memory:
Running this command provides the following output.
> filling jem.mwo.Interactions from db/data/jem.mwo-Interactions.csv > successfully deployed to sqlite in-memory db > updated ./package.json
and the package.json is updated
"cds": {
"requires": {
"db": {
"kind": "sqlite",
"model": "*",
"credentials": {
"database": ":memory:"
}
}
}
},
This approach allows me to avoid editing package.json manually or remembering to explicitly run from memory. Now I'm free to continue to work in memory until such times as I wish to deploy the model again to a persistent database using the more familiar call.
cds deploy --to sqlite:db/myWorkOrder
Perhaps you might find this useful.
Using
@sap/cds: 5.1.5 @sap/cds-compiler: 2.2.8 @sap/cds-dk: 4.1.5 @sap/cds-foss: 2.3.1 @sap/cds-runtime: 3.1.2 Node.js: v12.21.0
similar outcomes can be more simply achieved as follows:
Deployment to memory:
cds deploy --to sql
Deployment to persistent database:
cds deploy --to sqlite:/db/myWorkOrder
cds deploy with the option --no-save was used to ensure that the package.json was not updated. This option is now deprecated. cds deploy no longer modifies the package.json file.
In short - this means that the approach in this post does not work since the package.json file is not modified by the cds deploy commands.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 31 | |
| 18 | |
| 17 | |
| 16 | |
| 12 | |
| 10 | |
| 9 | |
| 8 | |
| 8 | |
| 7 |