added base V and E types

This commit is contained in:
Rasmus Neikes 2025-01-12 15:08:37 +01:00
parent c5f37a9b5b
commit 43473ebffc
2 changed files with 37 additions and 6 deletions

View File

@ -1,5 +1,8 @@
package com.stktrk.auth.integration.flyway; package com.stktrk.auth.integration.flyway;
import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.event.BeforeRecordCreateListener;
import com.arcadedb.gremlin.ArcadeGraph; import com.arcadedb.gremlin.ArcadeGraph;
import com.arcadedb.gremlin.ArcadeGraphFactory; import com.arcadedb.gremlin.ArcadeGraphFactory;
import com.stktrk.auth.integration.configuration.types.GraphDbConfig; import com.stktrk.auth.integration.configuration.types.GraphDbConfig;
@ -9,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.sql.Timestamp;
import java.util.Date;
/** /**
* provides connection pool for arcade DB * provides connection pool for arcade DB
@ -27,16 +32,17 @@ public class ConnectionPool {
*/ */
@PostConstruct @PostConstruct
void init() { void init() {
pool = ArcadeGraphFactory.withRemote(graphDbConfig.getHost(), pool = ArcadeGraphFactory.withRemote(graphDbConfig.getHost(),
graphDbConfig.getHttpPort(), graphDbConfig.getHttpPort(),
graphDbConfig.getGraphName(), graphDbConfig.getGraphName(),
graphDbConfig.getUser(), graphDbConfig.getUser(),
graphDbConfig.getPassword()); graphDbConfig.getPassword());
} }
/** /**
* Provides DB connection from pool * Provides DB connection from pool
* @return graphFactory to run queries against *
* @return graphFactory to run queries against
*/ */
@Nonnull @Nonnull
public static ArcadeGraph getGraph() { public static ArcadeGraph getGraph() {

View File

@ -0,0 +1,25 @@
package com.stktrk.auth.integration.flyway.migrations;
import com.stktrk.auth.integration.configuration.types.GraphDbConfig;
import com.stktrk.auth.integration.flyway.MigrationWrapper;
import jakarta.annotation.Nonnull;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@EqualsAndHashCode(callSuper = true)
@Component
@Value
public class V3__427__BaseTypes extends BaseJavaMigration implements MigrationWrapper {
@Nonnull
@Autowired
GraphDbConfig graphDbConfig;
public void migrate(@Nonnull Context context) throws Exception {
this.executeQuery(graphDbConfig,"CREATE VERTEX TYPE V IF NOT EXISTS; CREATE PROPERTY V.createdOn DATETIME (MANDATORY true, notnull true); CREATE PROPERTY V.createdBy STRING (MANDATORY true); CREATE PROPERTY V.changedOn DATETIME; CREATE PROPERTY V.changedBy STRING; CREATE EDGE TYPE E IF NOT EXISTS; CREATE PROPERTY E.createdOn DATETIME (MANDATORY true, notnull true); CREATE PROPERTY E.createdBy STRING (MANDATORY true); CREATE PROPERTY E.changedOn DATETIME; CREATE PROPERTY E.changedBy STRING; ALTER TYPE Account SUPERTYPE +V; Alter Type Role SUPERTYPE +V; Alter Type hasRole SUPERTYPE +E");
}
}