Skip to content

Commit d5621be

Browse files
Merge branch 'develop' into renovate/software.xdev-micro-migration-3.x
2 parents 7742308 + f3f83e7 commit d5621be

File tree

50 files changed

+1364
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1364
-50
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# 2.4.2
1+
# 2.5.0
22

33
* Updated org.springframework.boot.version to v3.4.1
4+
* Added support for the [micro-migration-Framework](https://github.com/xdev-software/micro-migration)
45

56
# 2.4.1
67

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ instructions** are in the documentation](https://xdev-software.github.io/spring-
5959
| ``2.2.0-2.3.1`` | ``17`` | ``3.3.4`` | ``1.4.0`` |
6060
| ``2.4.0`` | ``17`` | ``3.4.0`` | ``2.0.0`` |
6161
| ``2.4.1`` | ``17`` | ``3.4.0`` | ``2.1.0`` |
62-
| ``>= 2.4.2`` | ``17`` | ``3.4.1`` | ``2.1.0`` |
62+
| ``>= 2.5.0`` | ``17`` | ``3.4.1`` | ``2.1.0`` |
6363

6464
## Demo
6565

docs/antora.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: ROOT
22
title: Spring-Data-Eclipse-Store
33
version: master
4-
display_version: '2.4.1'
4+
display_version: '2.5.0'
55
start_page: index.adoc
66
nav:
77
- modules/ROOT/nav.adoc
88
asciidoc:
99
attributes:
1010
product-name: 'Spring-Data-Eclipse-Store'
11-
display-version: '2.4.1'
12-
maven-version: '2.4.1'
11+
display-version: '2.5.0'
12+
maven-version: '2.5.0'
1313
page-editable: false
1414
page-out-of-support: false

docs/modules/ROOT/nav.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
** xref:features/queries.adoc[Queries]
99
** xref:features/transactions.adoc[Transactions]
1010
** xref:features/versions.adoc[Versions]
11+
** xref:features/versioned-migration.adoc[Versioned Migration]
1112
** xref:features/rest-api.adoc[REST Interface]
1213
** xref:features/validation-constraints.adoc[Validation Constraints]
13-
* xref:migration.adoc[Migration from JPA]
14+
* xref:migration-from-jpa.adoc[Migration from JPA]
1415
* xref:known-issues.adoc[Known issues]

docs/modules/ROOT/pages/features/features.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
* xref:features/queries.adoc[Queries]
66
* xref:features/transactions.adoc[Transactions]
77
* xref:features/versions.adoc[Versions]
8+
* xref:features/versioned-migration.adoc[Versioned Migration]
89
* xref:features/rest-api.adoc[REST Interface]
910
* xref:features/validation-constraints.adoc[Validation Constraints]
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
= Versioned Migration
2+
3+
To keep the data in the store up-to-date, {product-name} utilizes https://github.com/xdev-software/micro-migration[XDEV's Micro-Migration].
4+
This means the user can use versioning for the stored data and only apply changes for certain versions of data.
5+
This can be very useful specifically with build-pipelines. https://github.com/xdev-software/micro-migration#intro[More info at Micro-Migration...]
6+
7+
== Implementation
8+
9+
This can be easily achieved by either of these 3 methods:
10+
11+
=== 1. Reflective Scripts
12+
13+
Simply implement a new component with a specific pattern of naming, that extends the ``ReflectiveDataMigrationScript``.
14+
15+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/migration/v1_0_0_Init.java[Reflective example from complex demo]"]
16+
----
17+
package software.xdev.spring.data.eclipse.store.demo.complex.migration;
18+
19+
import org.springframework.beans.factory.annotation.Autowired;
20+
import org.springframework.stereotype.Component;
21+
//...
22+
import software.xdev.spring.data.eclipse.store.repository.root.data.version.ReflectiveDataMigrationScript;
23+
24+
@Component
25+
public class v1_0_0_Init extends ReflectiveDataMigrationScript
26+
{
27+
private final OwnerService service;
28+
29+
@Autowired
30+
public v1_0_0_Init(final OwnerService service)
31+
{
32+
this.service = service;
33+
}
34+
35+
@Override
36+
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
37+
{
38+
this.service.createNewOwnerAndVisit("Mick", "Fleetwood", "Isabella");
39+
}
40+
}
41+
----
42+
43+
Here the version number on which the data is updated on execution is derived from the class name.
44+
45+
The ``MigrationVersion`` is stored in the root object in the data store.
46+
Therefore, the storage always knows on which version the current data is and the ``DataMigrater`` will only execute the newer scripts.
47+
48+
The scripts are automatically registered by declaring them as ``@Component``s.
49+
That means that they can be anywhere as long as they are discovered by Spring as a component.
50+
51+
=== 2. Custom Scripts
52+
53+
Implementing a script without special naming is possible by implementing the
54+
``DataMigrationScript``.
55+
56+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/migration/CustomNameScript.java[Custom script example from complex demo]"]
57+
----
58+
package software.xdev.spring.data.eclipse.store.demo.complex.migration;
59+
60+
import org.springframework.beans.factory.annotation.Autowired;
61+
import org.springframework.stereotype.Component;
62+
//...
63+
import software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrationScript;
64+
65+
@Component
66+
public class CustomNameScriptAddOwner implements DataMigrationScript
67+
{
68+
private final OwnerService service;
69+
70+
public CustomNameScriptAddOwner(@Autowired final OwnerService service)
71+
{
72+
this.service = service;
73+
}
74+
75+
@Override
76+
public MigrationVersion getTargetVersion()
77+
{
78+
return new MigrationVersion(1, 1, 0);
79+
}
80+
81+
@Override
82+
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
83+
{
84+
this.service.createNewOwnerAndVisit("John", "McVie", "Ivan");
85+
}
86+
}
87+
----
88+
89+
The version number must be returned explicitly in the ``#getTargetVersion``-method.
90+
91+
=== 3. Custom Migrater
92+
93+
If more customization is needed it is also possible to replace the ``DataMigrater`` completely and implement your own ``MicroMigrater``.
94+
This should only be used if necessary since it adds a lot of complexity to the code.
95+
96+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/data/migration/with/migrater/CustomMigrater.java[Custom migrater from tests]"]
97+
----
98+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.data.migration.with.migrater;
99+
100+
import org.springframework.beans.factory.annotation.Autowired;
101+
import org.springframework.stereotype.Component;
102+
import software.xdev.micromigration.migrater.ExplicitMigrater;
103+
import software.xdev.micromigration.migrater.MicroMigrater;
104+
//...
105+
106+
@Component
107+
public class CustomMigrater implements MicroMigrater
108+
{
109+
private final ExplicitMigrater explicitMigrater;
110+
111+
@Autowired
112+
public CustomMigrater(final PersistedEntityRepository repository)
113+
{
114+
this.explicitMigrater = new ExplicitMigrater(new v1_0_0_Init(repository));
115+
}
116+
----
File renamed without changes.

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>spring-data-eclipse-store-root</artifactId>
9-
<version>2.4.2-SNAPSHOT</version>
9+
<version>2.5.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>
@@ -107,7 +107,7 @@
107107
<dependency>
108108
<groupId>com.puppycrawl.tools</groupId>
109109
<artifactId>checkstyle</artifactId>
110-
<version>10.21.0</version>
110+
<version>10.21.1</version>
111111
</dependency>
112112
</dependencies>
113113
<configuration>
@@ -150,12 +150,12 @@
150150
<dependency>
151151
<groupId>net.sourceforge.pmd</groupId>
152152
<artifactId>pmd-core</artifactId>
153-
<version>7.8.0</version>
153+
<version>7.9.0</version>
154154
</dependency>
155155
<dependency>
156156
<groupId>net.sourceforge.pmd</groupId>
157157
<artifactId>pmd-java</artifactId>
158-
<version>7.8.0</version>
158+
<version>7.9.0</version>
159159
</dependency>
160160
</dependencies>
161161
</plugin>

spring-data-eclipse-store-benchmark/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<parent>
66
<groupId>software.xdev</groupId>
77
<artifactId>spring-data-eclipse-store-root</artifactId>
8-
<version>2.4.2-SNAPSHOT</version>
8+
<version>2.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>spring-data-eclipse-store-benchmark</artifactId>
12-
<version>2.4.2-SNAPSHOT</version>
12+
<version>2.5.0-SNAPSHOT</version>
1313
<packaging>jar</packaging>
1414

1515
<inceptionYear>2023</inceptionYear>

spring-data-eclipse-store-demo/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<parent>
88
<groupId>software.xdev</groupId>
99
<artifactId>spring-data-eclipse-store-root</artifactId>
10-
<version>2.4.2-SNAPSHOT</version>
10+
<version>2.5.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>spring-data-eclipse-store-demo</artifactId>
14-
<version>2.4.2-SNAPSHOT</version>
14+
<version>2.5.0-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>

0 commit comments

Comments
 (0)