Skip to content

Commit

Permalink
Merge pull request #1061 from folio-org/RMB-925-revert-postgres-versi…
Browse files Browse the repository at this point in the history
…on-check

Revert "RMB-913: Fail if PostgreSQL version is too old"
  • Loading branch information
julianladisch authored Jun 15, 2022
2 parents 2886851 + 3c3c5c1 commit 2924a24
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,6 @@ PostgresClient postgresClient(Context context) {
return PostgresClient.getInstance(context.owner());
}

Future<Void> requirePostgres(Context context, String minNum, String minVersion) {
return
postgresClient(context)
.select("SELECT current_setting('server_version_num') AS num, current_setting('server_version') AS version")
.map(rowSet -> {
String num = rowSet.iterator().next().getString("num");
String version = rowSet.iterator().next().getString("version");
if (minNum.compareTo(num) > 0) {
throw new UnsupportedOperationException(
"Expected PostgreSQL server version " + minVersion + " or later but found " + version);
}
return null;
});
}

Future<Void> requirePostgres12(Context context) {
return requirePostgres(context, "120000", "12.0");
}

Future<Boolean> tenantExists(Context context, String tenantId){
/* connect as user in postgres-conf.json file (super user) - so that all commands will be available */
return postgresClient(context).select(
Expand Down Expand Up @@ -226,8 +207,7 @@ private void postTenant(boolean async, TenantAttributes tenantAttributes, Map<St
job.setComplete(false);

String location = "/_/tenant/" + id;
requirePostgres12(context)
.compose(x -> tenantExists(context, tenantId))
tenantExists(context, tenantId)
.compose(exists -> sqlFile(context, tenantId, tenantAttributes, exists))
.onFailure(cause -> {
log.error(cause.getMessage(), cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.startsWith;
import static org.mockito.Mockito.*;

import java.io.IOException;
Expand Down Expand Up @@ -261,13 +260,6 @@ private void testMetadata(TestContext context) {
assertThat(book.getMetadata(), is(nullValue()));
}

@Test
public void requirePostgres(TestContext context) {
new TenantAPI().requirePostgres(vertx.getOrCreateContext(), "990000", "99.0")
.onComplete(context.asyncAssertFailure(
e -> assertThat(e.getMessage(), startsWith("Expected PostgreSQL server version 99.0 or later"))));
}

@Test
public void previousSchemaSqlExistsTrue(TestContext context) {
TenantAPI tenantAPI = new TenantAPI();
Expand Down Expand Up @@ -302,11 +294,6 @@ PostgresClient postgresClient(Context context) {
return postgresClient;
}

@Override
Future<Void> requirePostgres12(Context context) {
return Future.succeededFuture();
}

@Override
Future<Boolean> tenantExists(Context context, String tenantId) {
return Future.succeededFuture(false);
Expand All @@ -331,11 +318,6 @@ PostgresClient postgresClient(Context context) {
return postgresClient;
}

@Override
Future<Void> requirePostgres12(Context context) {
return Future.succeededFuture();
}

@Override
Future<Boolean> tenantExists(Context context, String tenantId) {
return Future.succeededFuture(false);
Expand Down

0 comments on commit 2924a24

Please sign in to comment.