diff --git a/pluto-server/pom.xml b/pluto-server/pom.xml index bf1b82a13fbfd2c886d9cb98eb4767ecf0849a1c..2366101b2ac727b65255aaa4913834d3a931c395 100644 --- a/pluto-server/pom.xml +++ b/pluto-server/pom.xml @@ -179,7 +179,35 @@ <version>1.15.3</version> <scope>test</scope> </dependency> + + <!-- mongock --> + <dependency> + <groupId>io.mongock</groupId> + <artifactId>mongock-springboot</artifactId> + <version>5.0.35</version> + </dependency> + <dependency> + <groupId>io.mongock</groupId> + <artifactId>mongock-driver-core</artifactId> + <version>5.0.35</version> + </dependency> + <dependency> + <groupId>io.mongock</groupId> + <artifactId>mongodb-springdata-v2-driver</artifactId> + <version>5.0.35</version> + </dependency> </dependencies> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>io.mongock</groupId> + <artifactId>mongock-core-bom</artifactId> + <version>5.0.35</version> + <type>pom</type> + </dependency> + </dependencies> + </dependencyManagement> <build> <finalName>${project.artifactId}</finalName> diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/PlutoServerApplication.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/PlutoServerApplication.java index d7877071d49965ac33a35b64f1376892516bdb11..1965aee359f201a9c6d58c2172a498652782c61a 100644 --- a/pluto-server/src/main/java/de/itvsh/ozg/pluto/PlutoServerApplication.java +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/PlutoServerApplication.java @@ -8,15 +8,17 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; +import io.mongock.runner.springboot.EnableMongock; + @SpringBootApplication(scanBasePackages = "de.itvsh.*") @EnableAsync @EnableScheduling @EnableAspectJAutoProxy(proxyTargetClass = true) +@EnableMongock public class PlutoServerApplication { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); SpringApplication.run(PlutoServerApplication.class, args); } - -} +} \ No newline at end of file diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/migration/TestCreateCollection.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/migration/TestCreateCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..913b0441d607d1ff70024ac2f7d30929c46dcd96 --- /dev/null +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/migration/TestCreateCollection.java @@ -0,0 +1,19 @@ +package de.itvsh.ozg.pluto.migration; + +import io.mongock.api.annotations.ChangeUnit; +import io.mongock.api.annotations.Execution; +import io.mongock.api.annotations.RollbackExecution; + +@ChangeUnit(id = "2022-01-21", order = "1", author = "mongock") +public class TestCreateCollection { + + @Execution + public void changeSet() { + System.out.println("Execution"); + } + + @RollbackExecution + public void doSomething() { + System.out.println("Rollback"); + } +} \ No newline at end of file diff --git a/pluto-server/src/main/resources/application-local.yml b/pluto-server/src/main/resources/application-local.yml index d4df97c8948c0d776396b2cc3bc4c713317c2932..894f19c15eaf292b04d1f31faff642d9e8fad9b6 100644 --- a/pluto-server/src/main/resources/application-local.yml +++ b/pluto-server/src/main/resources/application-local.yml @@ -9,10 +9,18 @@ server: management: server.port: 8083 +mongock: + runner-type: initializingbean + change-logs-scan-package: + - de.itvsh.ozg.pluto.migration + enabled: true + spring: data: mongodb: - database: pluto-local + database: pluto-local + #nur zum localen testen(sollte aus dem rancher gezogen werden) + uri: mongodb://localhost:27018/test mail: username: ea@ozg-sh.de password: skdljf39jx