Skip to content

migrate to 'ds' schema in the postgres database #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/org/gridsuite/ds/server/DatabaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ public class DatabaseConfig extends AbstractR2dbcConfiguration {
@Override
public ConnectionFactory connectionFactory() {
String driver = env.getRequiredProperty("driver");
String schema = env.getProperty("schema", "");
if (driver.equals("h2")) {
return new H2ConnectionFactory(H2ConnectionConfiguration.builder()
.inMemory(env.getRequiredProperty("database"))
.option("DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")
.option("DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS " + schema + "\\;SET SCHEMA " + schema)
.build());
} else if (driver.equals("postgresql")) {
return new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
Expand All @@ -49,7 +50,7 @@ public ConnectionFactory connectionFactory() {
.database(env.getRequiredProperty("database"))
.username(env.getRequiredProperty("login"))
.password(env.getRequiredProperty("password"))
.schema(env.getProperty("schema", ""))
.schema(schema)
.build());
} else {
throw new DynamicSimulationException(DynamicSimulationException.Type.DATABASE_DRIVER_NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public DynamicSimulationController(DynamicSimulationService dynamicSimulationSer
this.dynamicSimulationService = dynamicSimulationService;
}

@PostMapping(value = "/networks/{networkUuid}/run", produces = "application/json")
@PostMapping(value = "/networks/{networkUuid}/run", produces = "application/json", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(summary = "run the dynamic simulation")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "")})
public ResponseEntity<Mono<UUID>> run(@PathVariable("networkUuid") UUID networkUuid,
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/database.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
driver=postgresql
host=localhost
database=ds
database=gridsuite
schema=ds
login=postgres
password=postgres
port=5432
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/database.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
driver=h2
database=my_test_db
schema=ds