diff --git a/pom.xml b/pom.xml index 96852c4..a9856cb 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,14 @@ org.flywaydb flyway-core + + + org.flywaydb + flyway-database-postgresql + 10.4.1 + + + org.springframework.session spring-session-core @@ -140,7 +148,6 @@ - org.opencypher.gremlin @@ -183,6 +190,38 @@ + + org.flywaydb + flyway-maven-plugin + 10.17.2 + + __ + + filesystem:src/main/resources/db/migration + classpath:com/stktrk/app/db/migrations + + + jdbc:postgresql://192.168.178.50:7654/flyway_db + flyway_user + 7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi + flyway_db + + + + + + + + + org.postgresql + postgresql + 42.7.4 + + + + + + diff --git a/src/main/java/com/stktrk/app/db/migrations/V1__CreateTest.java b/src/main/java/com/stktrk/app/db/migrations/V1__CreateTest.java new file mode 100644 index 0000000..e21fe06 --- /dev/null +++ b/src/main/java/com/stktrk/app/db/migrations/V1__CreateTest.java @@ -0,0 +1,36 @@ +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 V1__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"); + + connection.close(); + + } catch (Exception e) { + + System.out.println (e); + + } + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 650f1d8..a11ec6c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,7 @@ spring.application.name=app server.port=9090 -springdoc.swagger-ui.path=/swagger-ui.html \ No newline at end of file +springdoc.swagger-ui.path=/swagger-ui.html + +flyway.user=flyway_user +flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi +flyway.schemas=flyway_db \ No newline at end of file