abort schema initialization if HFJ_RESOURCE table already exists
This commit is contained in:
parent
5577680a85
commit
0404454167
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.jpa.migrate.taskdef;
|
package ca.uhn.fhir.jpa.migrate.taskdef;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
|
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
|
||||||
|
import ca.uhn.fhir.jpa.migrate.JdbcUtils;
|
||||||
import ca.uhn.fhir.jpa.migrate.tasks.api.ISchemaInitializationProvider;
|
import ca.uhn.fhir.jpa.migrate.tasks.api.ISchemaInitializationProvider;
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
|
@ -10,6 +11,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class InitializeSchemaTask extends BaseTask<InitializeSchemaTask> {
|
public class InitializeSchemaTask extends BaseTask<InitializeSchemaTask> {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(InitializeSchemaTask.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(InitializeSchemaTask.class);
|
||||||
|
@ -29,6 +31,12 @@ public class InitializeSchemaTask extends BaseTask<InitializeSchemaTask> {
|
||||||
public void execute() throws SQLException {
|
public void execute() throws SQLException {
|
||||||
DriverTypeEnum driverType = getDriverType();
|
DriverTypeEnum driverType = getDriverType();
|
||||||
|
|
||||||
|
Set<String> tableNames = JdbcUtils.getTableNames(getConnectionProperties());
|
||||||
|
if (tableNames.contains("HFJ_RESOURCE")) {
|
||||||
|
logInfo(ourLog, "The table HFJ_RESOURCE already exists. Skipping schema initialization for {}", driverType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
logInfo(ourLog, "Initializing schema for {}", driverType);
|
logInfo(ourLog, "Initializing schema for {}", driverType);
|
||||||
|
|
||||||
List<String> sqlStatements = mySchemaInitializationProvider.getSqlStatements(driverType);
|
List<String> sqlStatements = mySchemaInitializationProvider.getSqlStatements(driverType);
|
||||||
|
|
Loading…
Reference in New Issue