added resource table to hsql schema

This commit is contained in:
YevhenBondarenko 2021-03-05 19:10:44 +02:00
parent 616839a23c
commit c78bd55df5
4 changed files with 16 additions and 1 deletions

View File

@ -35,6 +35,7 @@ import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.entity.AbstractEntityService; import org.thingsboard.server.dao.entity.AbstractEntityService;
import org.thingsboard.server.dao.entityview.EntityViewService; import org.thingsboard.server.dao.entityview.EntityViewService;
import org.thingsboard.server.dao.exception.DataValidationException; import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.resource.ResourceService;
import org.thingsboard.server.dao.rule.RuleChainService; import org.thingsboard.server.dao.rule.RuleChainService;
import org.thingsboard.server.dao.service.DataValidator; import org.thingsboard.server.dao.service.DataValidator;
import org.thingsboard.server.dao.service.PaginatedRemover; import org.thingsboard.server.dao.service.PaginatedRemover;
@ -88,6 +89,9 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
@Autowired @Autowired
private RuleChainService ruleChainService; private RuleChainService ruleChainService;
@Autowired
private ResourceService resourceService;
@Override @Override
public Tenant findTenantById(TenantId tenantId) { public Tenant findTenantById(TenantId tenantId) {
log.trace("Executing findTenantById [{}]", tenantId); log.trace("Executing findTenantById [{}]", tenantId);
@ -140,6 +144,7 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
userService.deleteTenantAdmins(tenantId); userService.deleteTenantAdmins(tenantId);
ruleChainService.deleteRuleChainsByTenantId(tenantId); ruleChainService.deleteRuleChainsByTenantId(tenantId);
apiUsageStateService.deleteApiUsageStateByTenantId(tenantId); apiUsageStateService.deleteApiUsageStateByTenantId(tenantId);
resourceService.deleteResourcesByTenantId(tenantId);
tenantDao.removeById(tenantId, tenantId.getId()); tenantDao.removeById(tenantId, tenantId.getId());
deleteEntityRelations(tenantId, tenantId); deleteEntityRelations(tenantId, tenantId);
} }

View File

@ -420,3 +420,11 @@ CREATE TABLE IF NOT EXISTS api_usage_state (
sms_exec varchar(32), sms_exec varchar(32),
CONSTRAINT api_usage_state_unq_key UNIQUE (tenant_id, entity_id) CONSTRAINT api_usage_state_unq_key UNIQUE (tenant_id, entity_id)
); );
CREATE TABLE IF NOT EXISTS resource (
tenant_id uuid NOT NULL,
resource_type varchar(32) NOT NULL,
resource_id varchar(255) NOT NULL,
resource_value varchar,
CONSTRAINT resource_unq_key UNIQUE (tenant_id, resource_type, resource_id)
);

View File

@ -28,4 +28,5 @@ DROP TABLE IF EXISTS oauth2_client_registration;
DROP TABLE IF EXISTS oauth2_client_registration_info; DROP TABLE IF EXISTS oauth2_client_registration_info;
DROP TABLE IF EXISTS oauth2_client_registration_template; DROP TABLE IF EXISTS oauth2_client_registration_template;
DROP TABLE IF EXISTS api_usage_state; DROP TABLE IF EXISTS api_usage_state;
DROP TABLE IF EXISTS resource;
DROP FUNCTION IF EXISTS to_uuid; DROP FUNCTION IF EXISTS to_uuid;

View File

@ -28,4 +28,5 @@ DROP TABLE IF EXISTS tb_schema_settings;
DROP TABLE IF EXISTS oauth2_client_registration; DROP TABLE IF EXISTS oauth2_client_registration;
DROP TABLE IF EXISTS oauth2_client_registration_info; DROP TABLE IF EXISTS oauth2_client_registration_info;
DROP TABLE IF EXISTS oauth2_client_registration_template; DROP TABLE IF EXISTS oauth2_client_registration_template;
DROP TABLE IF EXISTS api_usage_state; DROP TABLE IF EXISTS api_usage_state;
DROP TABLE IF EXISTS resource;