Merge pull request 'flyway-setup-1' (#5) from flyway-setup-1 into main
Reviewed-on: binarygolem/stktrk#5
This commit is contained in:
commit
c664aca308
42
pom.xml
42
pom.xml
@ -50,6 +50,14 @@
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-database-postgresql -->
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-database-postgresql</artifactId>
|
||||
<version>10.4.1</version>
|
||||
<!-- <scope>runtime</scope> -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-core</artifactId>
|
||||
@ -140,7 +148,6 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.opencypher/util-9.0 -->
|
||||
<dependency>
|
||||
<groupId>org.opencypher.gremlin</groupId>
|
||||
@ -183,6 +190,39 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-maven-plugin</artifactId>
|
||||
<version>10.17.2</version>
|
||||
<configuration>
|
||||
<sqlMigrationSeparator>__</sqlMigrationSeparator>
|
||||
<locations>
|
||||
<location>classpath:com/stktrk/app/db/migrations</location>
|
||||
</locations>
|
||||
|
||||
<url>jdbc:postgresql://192.168.178.50:7654/flyway_db</url>
|
||||
<user>flyway_user</user>
|
||||
<password>7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi</password>
|
||||
<schemas>
|
||||
<schema>flyway_db</schema>
|
||||
</schemas>
|
||||
|
||||
|
||||
</configuration>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.7.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
|
||||
@ -3,7 +3,9 @@ package com.stktrk.app;
|
||||
import com.arcadedb.gremlin.ArcadeGraph;
|
||||
|
||||
import com.github.javafaker.Faker;
|
||||
import com.stktrk.app.configuration.GraphDbConfig;
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@ -2,20 +2,30 @@ package com.stktrk.app;
|
||||
|
||||
import com.arcadedb.gremlin.ArcadeGraph;
|
||||
import com.arcadedb.gremlin.ArcadeGraphFactory;
|
||||
import com.stktrk.app.configuration.GraphDbConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
public class ConnectionPool {
|
||||
static final ArcadeGraphFactory pool;
|
||||
static ArcadeGraphFactory pool;
|
||||
|
||||
|
||||
static {
|
||||
@Autowired
|
||||
GraphDbConfig graphDbConfig;
|
||||
|
||||
@PostConstruct
|
||||
void init () {
|
||||
try {
|
||||
pool = ArcadeGraphFactory.withRemote("192.168.178.50", 2480, "graph", "root", "playwithdata");
|
||||
pool = ArcadeGraphFactory.withRemote(graphDbConfig.getHost(), graphDbConfig.getHttpPort(), graphDbConfig.getGraphName(), graphDbConfig.getUser(), graphDbConfig.getPassword());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ArcadeGraph getGraph(){
|
||||
public static ArcadeGraph getGraph() {
|
||||
return pool.get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package com.stktrk.app.configuration;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties(prefix = "graph")
|
||||
|
||||
public class GraphDbConfig {
|
||||
String host;
|
||||
int httpPort;
|
||||
int postgresPort;
|
||||
String graphName;
|
||||
String user;
|
||||
String password;
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.stktrk.app.db.migrations;
|
||||
|
||||
import org.flywaydb.core.api.migration.BaseJavaMigration;
|
||||
import org.flywaydb.core.api.migration.Context;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class V2__CreateTest extends BaseJavaMigration {
|
||||
public void migrate(Context context) throws Exception {
|
||||
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("user", "root");
|
||||
props.setProperty("password", "playwithdata");
|
||||
props.setProperty("ssl", "false");
|
||||
props.setProperty("sslmode", "disable");
|
||||
|
||||
System.out.println ("migration");
|
||||
|
||||
|
||||
try (Connection connection = DriverManager.getConnection("jdbc:postgresql://192.168.178.50:5432/graph", props)) {
|
||||
|
||||
Statement st = connection.createStatement();
|
||||
st.execute("CREATE VERTEX TYPE test");
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println (e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,16 @@
|
||||
spring.application.name=app
|
||||
server.port=9090
|
||||
springdoc.swagger-ui.path=/swagger-ui.html
|
||||
|
||||
flyway.user=flyway_user
|
||||
flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
|
||||
flyway.schemas=flyway_db
|
||||
|
||||
|
||||
graph.user=root
|
||||
graph.password=playwithdata
|
||||
graph.connection=jdbc:postgresql://192.168.178.50:5432/graph
|
||||
graph.http-port:2480
|
||||
graph.postgres-port:5432
|
||||
graph.host=192.168.178.50
|
||||
graph.graph-name=graph
|
||||
Loading…
Reference in New Issue
Block a user