Skip to content

Commit 38e09ea

Browse files
committed
ai-assisted edit
1 parent ee690e4 commit 38e09ea

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

guides/databases/schema-evolution.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Schema evolution is the capability of a database to adapt its schema (tables, co
88

99
## Drop-Create in Development
1010

11-
During development, schema evolution is typically handled using a "drop-create" strategy, where the existing databases or schemas are dropped and recreated based on the current CDS model. This approach is simple and effective, and most suitable for development phases, as it:
11+
During development, schema evolution is typically handled using a "drop-create" strategy, where you drop and recreate the existing databases or schemas based on the current CDS model. This approach is simple and effective, and most suitable for development phases, as it:
1212

13-
- allows developers to quickly iterate on their data models
14-
- with incompatible changes being the standard, such as
15-
- adding, removing, or renaming entities and fields
13+
- Allows you to quickly iterate on your data models
14+
- Makes incompatible changes the standard, such as:
15+
- Adding, removing, or renaming entities and fields
1616

17-
We see that in action when running `cds deploy`, which generates the necessary SQL statements to drop existing tables and recreate them or new ones according to the current CDS definitions:
17+
You can see this in action when you run `cds deploy`, which generates the necessary SQL statements to drop existing tables and recreate them or new ones according to the current CDS definitions:
1818

1919
```shell
2020
cds deploy --dry
@@ -38,7 +38,7 @@ In addition to dropping and recreating tables in-place, you can and should also
3838
## Schema Evolution by CAP
3939

4040

41-
In production environments, a drop-create strategy is not feasible, as it would result in data loss. CAP provides mechanisms to handle schema evolution in a more controlled manner, by generating migration scripts that can be reviewed and applied to the database.
41+
In production environments, you can't use a drop-create strategy, as it would result in data loss. CAP provides mechanisms to handle schema evolution in a more controlled manner, by generating migration scripts that you can review and apply to the database.
4242

4343
Let's simulate the workflow with the [@capire/bookshop](https://github.com/capire/bookshop) example.
4444

@@ -47,7 +47,7 @@ Let's simulate the workflow with the [@capire/bookshop](https://github.com/capir
4747
cds deploy --dry --model-only -o former.csn
4848
```
4949

50-
2. Make changes to our models, for example let's edit `db/schema.cds` like this:
50+
2. Make changes to your models. For example, edit `db/schema.cds` like this:
5151

5252
::: code-group
5353
```cds [db/schema.cds]
@@ -113,17 +113,17 @@ Let's simulate the workflow with the [@capire/bookshop](https://github.com/capir
113113

114114
### Disallowed Changes
115115

116-
Some changes to the CDS model are considered disallowed in the context of schema evolution, as they could lead to data loss or inconsistencies. Examples of such changes include:
116+
Some changes to the CDS model are considered disallowed in the context of schema evolution, as they could lead to data loss or inconsistencies. The following list shows examples of such changes:
117117

118118
- Renaming entities or fields (instead, add new ones and migrate data)
119119
- Changing data types in incompatible ways (e.g., from String to Integer)
120120
- Removing entities or fields (instead, consider deprecating them first)
121121
- Reducing the length of strings or binary fields
122122
- Reducing the precision of numeric fields
123123

124-
When such disallowed changes are detected during the generation of migration scripts, `cds deploy --script` will print a warning, and also add corresponding comments to the generated SQL script, which can then be reviewed and addressed manually.
124+
When `cds deploy --script` detects such disallowed changes during the generation of migration scripts, it prints a warning and adds corresponding comments to the generated SQL script, which you can then review and address manually.
125125

126-
For example, if we would rename the `descr` field to `details` like that:
126+
For example, if you rename the `descr` field to `details` like this:
127127

128128
::: code-group
129129
```cds [db/schema.cds]
@@ -171,14 +171,14 @@ You can enable automatic schema evolution in your `db` configuration:
171171
```
172172
:::
173173

174-
This will enable automatic schema migration when running `cds deploy` in production-like environments as follows:
174+
This enables automatic schema migration when you run `cds deploy` in production-like environments. The migration process works as follows:
175175

176-
- Whenever a `cds deploy` is executed successfully, the resulting state of the database schema is stored in an internal table.
176+
- Whenever you execute `cds deploy` successfully, CAP stores the resulting state of the database schema in an internal table.
177177

178-
- Before applying any changes, CAP compares the new state of the CDS models with the stored state. Any differences are translated into appropriate SQL statements to migrate the schema.
178+
- Before applying any changes, CAP compares the new state of the CDS models with the stored state and translates any differences into appropriate SQL statements to migrate the schema.
179179

180180
> [!important]
181-
> Only non-lossy changes are applied automatically. If lossy changes are detected, `cds deploy` will abort with respective errors and include comments in the generated SQL script, similar to the general approach described above.
181+
> CAP applies only non-lossy changes automatically. If it detects lossy changes, `cds deploy` aborts with respective errors and includes comments in the generated SQL script, similar to the general approach described above.
182182
183183

184184
## Schema Evolution by HDI
@@ -193,6 +193,6 @@ Learn more about that in the [SAP HANA](hana.md) guide, section [HDI Schema Evol
193193

194194
## Liquibase for Java Projects
195195

196-
For Java-based CAP projects, you can also use [Liquibase](https://www.liquibase.org/) to control when, where, and how database changes are deployed.
196+
For Java-based CAP projects, you can also use [Liquibase](https://www.liquibase.org/) to control when, where, and how you deploy database changes.
197197

198198
Learn more about that in the [PostgreSQL](postgres.md) guide, section [Using Liquibase (Java)](postgres#using-liquibase-java).

0 commit comments

Comments
 (0)