|
|
|
@ -15,11 +15,20 @@ |
|
|
|
*/ |
|
|
|
package org.thingsboard.server.service.install; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.context.annotation.Profile; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.thingsboard.server.dao.util.HsqlDao; |
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.DriverManager; |
|
|
|
|
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
@HsqlDao |
|
|
|
@Profile("install") |
|
|
|
public class HsqlEntityDatabaseSchemaService extends SqlAbstractDatabaseSchemaService |
|
|
|
@ -27,5 +36,21 @@ public class HsqlEntityDatabaseSchemaService extends SqlAbstractDatabaseSchemaSe |
|
|
|
protected HsqlEntityDatabaseSchemaService() { |
|
|
|
super("schema-entities-hsql.sql", "schema-entities-idx.sql"); |
|
|
|
} |
|
|
|
|
|
|
|
private final String schemaTypesSql = "schema-types-hsql.sql"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void createDatabaseSchema(boolean createIndexes) throws Exception { |
|
|
|
|
|
|
|
log.info("Installing SQL DataBase types part: " + schemaTypesSql); |
|
|
|
|
|
|
|
Path schemaFile = Paths.get(installScripts.getDataDir(), SQL_DIR, schemaTypesSql); |
|
|
|
try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) { |
|
|
|
String sql = new String(Files.readAllBytes(schemaFile), Charset.forName("UTF-8")); |
|
|
|
conn.createStatement().execute(sql); //NOSONAR, ignoring because method used to load initial thingsboard database schema
|
|
|
|
} |
|
|
|
|
|
|
|
super.createDatabaseSchema(createIndexes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|