init: Default database type to JDBC when url is present
If there is no type named in the database section but url is set force the type to be JDBC. This fixes an upgrade path from 2.1.8 to 2.6 where previously Gerrit assumed JDBC type when url was present and no type was given. Bug: issue 1870 Change-Id: I8e30456dd9bb292fc8fc1d9f253413cd676d48ba
This commit is contained in:
@@ -16,6 +16,8 @@ package com.google.gerrit.pgm.init;
|
||||
|
||||
import static com.google.inject.Stage.PRODUCTION;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.pgm.util.ConsoleUI;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.inject.Binding;
|
||||
@@ -53,7 +55,7 @@ class InitDatabase implements InitStep {
|
||||
public void run() {
|
||||
ui.header("SQL Database");
|
||||
|
||||
Set<String> allowedValues = new TreeSet<String>();
|
||||
Set<String> allowedValues = Sets.newTreeSet();
|
||||
Injector i = Guice.createInjector(PRODUCTION, new DatabaseConfigModule(site));
|
||||
List<Binding<DatabaseConfigInitializer>> dbConfigBindings =
|
||||
i.findBindingsByType(new TypeLiteral<DatabaseConfigInitializer>() {});
|
||||
@@ -64,6 +66,11 @@ class InitDatabase implements InitStep {
|
||||
}
|
||||
}
|
||||
|
||||
if (!Strings.isNullOrEmpty(database.get("url"))
|
||||
&& Strings.isNullOrEmpty(database.get("type"))) {
|
||||
database.set("type", "jdbc");
|
||||
}
|
||||
|
||||
String dbType =
|
||||
database.select("Database server type", "type", "h2", allowedValues);
|
||||
|
||||
|
Reference in New Issue
Block a user