Browse Source

added resource table to hsql schema

pull/4213/head
YevhenBondarenko 6 years ago
parent
commit
c78bd55df5
  1. 5
      dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java
  2. 8
      dao/src/main/resources/sql/schema-entities-hsql.sql
  3. 1
      dao/src/test/resources/sql/hsql/drop-all-tables.sql
  4. 3
      dao/src/test/resources/sql/psql/drop-all-tables.sql

5
dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java

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

8
dao/src/main/resources/sql/schema-entities-hsql.sql

@ -420,3 +420,11 @@ CREATE TABLE IF NOT EXISTS api_usage_state (
sms_exec varchar(32),
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)
);

1
dao/src/test/resources/sql/hsql/drop-all-tables.sql

@ -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_template;
DROP TABLE IF EXISTS api_usage_state;
DROP TABLE IF EXISTS resource;
DROP FUNCTION IF EXISTS to_uuid;

3
dao/src/test/resources/sql/psql/drop-all-tables.sql

@ -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_info;
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;

Loading…
Cancel
Save