private Optional<Version> getVersionFromSchemaVersionTable(final Connection connection) {
        Optional<Version> optVersion = Optional.empty();
        try {
            try (final Statement statement = connection.createStatement()) {
                try (final ResultSet resultSet = statement.executeQuery("""
                        SELECT version
                        FROM schema_version
                        ORDER BY installed_rank DESC""")) {
                    if (resultSet.next()) {
                        final String ver = resultSet.getString(1);
                        final String[] parts = ver.split("\\.");
                        int maj = 0;
                        int min = 0;
                        int pat = 0;
                        if (parts.length > 0) {
                            maj = Integer.parseInt(parts[0]);
                        }
                        if (parts.length > 1) {
                            min = Integer.parseInt(parts[1]);
                        }
                        if (parts.length > 2) {
                            pat = Integer.parseInt(parts[2]);
                        }

                        LOGGER.info("Found schema_version.version " + ver);
                        optVersion = Optional.of(new Version(maj, min, pat));
                    }

                }
            }
        } catch (final SQLException e) {
            LOGGER.debug(e.getMessage());
            // Ignore.
        }
        return optVersion;
    }
Configures anything related to persistence, e.g. transaction management, the
entity manager factory, data sources.
<p>
This does not extend {@link stroom.db.util.AbstractDataSourceProviderModule} as the core migrations
are special and need to happen first before all the other migrations. {@link ForceLegacyMigration} is
used to achieve this by making all other datasource providers depend on {@link ForceLegacyMigration}.
stroom-legacy/stroom-legacy-db-migration/src/main/java/stroom/legacy/db/LegacyDbModule.java