setup flyway with separate postgres for history info
This commit is contained in:
parent
0d8f4c63d4
commit
51485e68a2
5
pom.xml
5
pom.xml
@ -197,14 +197,15 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<sqlMigrationSeparator>__</sqlMigrationSeparator>
|
<sqlMigrationSeparator>__</sqlMigrationSeparator>
|
||||||
<locations>
|
<locations>
|
||||||
<location>filesystem:src/main/resources/db/migration</location>
|
|
||||||
<location>classpath:com/stktrk/app/db/migrations</location>
|
<location>classpath:com/stktrk/app/db/migrations</location>
|
||||||
</locations>
|
</locations>
|
||||||
|
|
||||||
<url>jdbc:postgresql://192.168.178.50:7654/flyway_db</url>
|
<url>jdbc:postgresql://192.168.178.50:7654/flyway_db</url>
|
||||||
<user>flyway_user</user>
|
<user>flyway_user</user>
|
||||||
<password>7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi</password>
|
<password>7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi</password>
|
||||||
<schemas><schema>flyway_db</schema></schemas>
|
<schemas>
|
||||||
|
<schema>flyway_db</schema>
|
||||||
|
</schemas>
|
||||||
|
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -3,7 +3,9 @@ package com.stktrk.app;
|
|||||||
import com.arcadedb.gremlin.ArcadeGraph;
|
import com.arcadedb.gremlin.ArcadeGraph;
|
||||||
|
|
||||||
import com.github.javafaker.Faker;
|
import com.github.javafaker.Faker;
|
||||||
|
import com.stktrk.app.configuration.GraphDbConfig;
|
||||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|||||||
@ -2,14 +2,24 @@ package com.stktrk.app;
|
|||||||
|
|
||||||
import com.arcadedb.gremlin.ArcadeGraph;
|
import com.arcadedb.gremlin.ArcadeGraph;
|
||||||
import com.arcadedb.gremlin.ArcadeGraphFactory;
|
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 {
|
public class ConnectionPool {
|
||||||
static final ArcadeGraphFactory pool;
|
static ArcadeGraphFactory pool;
|
||||||
|
|
||||||
|
|
||||||
static {
|
@Autowired
|
||||||
|
GraphDbConfig graphDbConfig;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
void init () {
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -6,7 +6,7 @@ import org.flywaydb.core.api.migration.Context;
|
|||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class V1__CreateTest extends BaseJavaMigration {
|
public class V2__CreateTest extends BaseJavaMigration {
|
||||||
public void migrate(Context context) throws Exception {
|
public void migrate(Context context) throws Exception {
|
||||||
|
|
||||||
Class.forName("org.postgresql.Driver");
|
Class.forName("org.postgresql.Driver");
|
||||||
@ -25,7 +25,6 @@ public class V1__CreateTest extends BaseJavaMigration {
|
|||||||
Statement st = connection.createStatement();
|
Statement st = connection.createStatement();
|
||||||
st.execute("CREATE VERTEX TYPE test");
|
st.execute("CREATE VERTEX TYPE test");
|
||||||
|
|
||||||
connection.close();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
@ -5,3 +5,12 @@ springdoc.swagger-ui.path=/swagger-ui.html
|
|||||||
flyway.user=flyway_user
|
flyway.user=flyway_user
|
||||||
flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
|
flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
|
||||||
flyway.schemas=flyway_db
|
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