Browse Source

feature: support database, schema config (#44)

* feat: add schema_name

* feat: support database, schema config

* feat: add more detail info in databaseTypes

* feat: add permission control to databaseType api

* feat: update frontend resources
master
vran 3 years ago
committed by GitHub
parent
commit
f026d406a2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      api/src/main/java/com/databasir/api/DatabaseTypeController.java
  2. 13
      api/src/main/java/com/databasir/api/validator/DatabaseTypeValidator.java
  3. 0
      api/src/main/resources/static/css/395.edb95c8a.css
  4. 0
      api/src/main/resources/static/css/459.82a2f213.css
  5. 2
      api/src/main/resources/static/index.html
  6. 4
      api/src/main/resources/static/js/117-legacy.72d604e3.js
  7. 1
      api/src/main/resources/static/js/117-legacy.72d604e3.js.map
  8. 4
      api/src/main/resources/static/js/269-legacy.1ed6e867.js
  9. 1
      api/src/main/resources/static/js/269-legacy.1ed6e867.js.map
  10. 1
      api/src/main/resources/static/js/269-legacy.b06c44d2.js.map
  11. 1
      api/src/main/resources/static/js/269.3d925388.js.map
  12. 4
      api/src/main/resources/static/js/269.fb28ff39.js
  13. 1
      api/src/main/resources/static/js/269.fb28ff39.js.map
  14. 1
      api/src/main/resources/static/js/306.836b767d.js.map
  15. 6
      api/src/main/resources/static/js/395-legacy.e525ab53.js
  16. 1
      api/src/main/resources/static/js/395-legacy.e525ab53.js.map
  17. 6
      api/src/main/resources/static/js/395.f7b88568.js
  18. 1
      api/src/main/resources/static/js/395.f7b88568.js.map
  19. 2
      api/src/main/resources/static/js/459-legacy.5a5a02e8.js
  20. 1
      api/src/main/resources/static/js/459-legacy.5a5a02e8.js.map
  21. 2
      api/src/main/resources/static/js/459.22e837b8.js
  22. 1
      api/src/main/resources/static/js/459.22e837b8.js.map
  23. 2
      api/src/main/resources/static/js/506-legacy.5b373ce0.js
  24. 1
      api/src/main/resources/static/js/506-legacy.5b373ce0.js.map
  25. 2
      api/src/main/resources/static/js/506.128427e0.js
  26. 1
      api/src/main/resources/static/js/506.128427e0.js.map
  27. 4
      api/src/main/resources/static/js/564.07fcac27.js
  28. 1
      api/src/main/resources/static/js/564.07fcac27.js.map
  29. 1
      api/src/main/resources/static/js/809-legacy.1f0d7d41.js.map
  30. 1
      api/src/main/resources/static/js/898-legacy.13f30c0d.js.map
  31. 1
      api/src/main/resources/static/js/898.a81fbbe7.js.map
  32. 4
      api/src/main/resources/static/js/app-legacy.2527a373.js
  33. 2
      api/src/main/resources/static/js/app-legacy.2527a373.js.map
  34. 4
      api/src/main/resources/static/js/app.a4b9bb20.js
  35. 2
      api/src/main/resources/static/js/app.a4b9bb20.js.map
  36. 15
      core/src/main/java/com/databasir/core/domain/database/data/DatabaseTypeSimpleResponse.java
  37. 11
      core/src/main/java/com/databasir/core/domain/database/service/DatabaseTypeService.java
  38. 1
      core/src/main/java/com/databasir/core/domain/document/converter/DocumentPojoConverter.java
  39. 2
      core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentResponse.java
  40. 2
      core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentSimpleResponse.java
  41. 2
      core/src/main/java/com/databasir/core/domain/document/service/DocumentService.java
  42. 3
      core/src/main/java/com/databasir/core/domain/project/data/ProjectCreateRequest.java
  43. 2
      core/src/main/java/com/databasir/core/domain/project/data/ProjectDetailResponse.java
  44. 6
      core/src/main/java/com/databasir/core/domain/project/data/ProjectListCondition.java
  45. 2
      core/src/main/java/com/databasir/core/domain/project/data/ProjectSimpleResponse.java
  46. 3
      core/src/main/java/com/databasir/core/domain/project/data/ProjectTestConnectionRequest.java
  47. 3
      core/src/main/java/com/databasir/core/domain/project/data/ProjectUpdateRequest.java
  48. 1
      core/src/main/java/com/databasir/core/domain/project/service/ProjectService.java
  49. 3
      core/src/main/java/com/databasir/core/infrastructure/connection/CustomDatabaseConnectionFactory.java
  50. 4
      core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionFactory.java
  51. 7
      core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionService.java
  52. 2
      core/src/main/java/com/databasir/core/infrastructure/connection/MysqlDatabaseConnectionFactory.java
  53. 2
      core/src/main/java/com/databasir/core/infrastructure/connection/PostgresqlDatabaseConnectionFactory.java
  54. 15
      dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSource.java
  55. 33
      dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocument.java
  56. 19
      dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePojo.java
  57. 19
      dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentPojo.java
  58. 122
      dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourceRecord.java
  59. 122
      dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentRecord.java
  60. 20
      dao/src/main/resources/db/migration/V1__init.sql
  61. 3
      plugin/src/main/java/com/databasir/core/Databasir.java
  62. 5
      plugin/src/main/java/com/databasir/core/meta/data/DatabaseMeta.java
  63. 2
      plugin/src/main/java/com/databasir/core/meta/repository/condition/Condition.java
  64. 1
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java
  65. 2
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java

9
api/src/main/java/com/databasir/api/DatabaseTypeController.java

@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PageableDefault;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -28,9 +29,8 @@ public class DatabaseTypeController {
private final DatabaseTypeValidator databaseTypeValidator; private final DatabaseTypeValidator databaseTypeValidator;
@GetMapping(Routes.DatabaseType.LIST_SIMPLE) @GetMapping(Routes.DatabaseType.LIST_SIMPLE)
public JsonData<List<String>> listSimpleDatabaseTypes() { public JsonData<List<DatabaseTypeSimpleResponse>> listSimpleDatabaseTypes() {
List<String> types = databaseTypeService.listSimpleDatabaseTypes(); return JsonData.ok(databaseTypeService.listSimpleDatabaseTypes());
return JsonData.ok(types);
} }
@GetMapping(Routes.DatabaseType.LIST_PAGE) @GetMapping(Routes.DatabaseType.LIST_PAGE)
@ -43,6 +43,7 @@ public class DatabaseTypeController {
@PostMapping(Routes.DatabaseType.CREATE) @PostMapping(Routes.DatabaseType.CREATE)
@Operation(module = Operation.Modules.DATABASE_TYPE, name = "创建数据库类型") @Operation(module = Operation.Modules.DATABASE_TYPE, name = "创建数据库类型")
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
public JsonData<Integer> create(@RequestBody @Valid DatabaseTypeCreateRequest request) { public JsonData<Integer> create(@RequestBody @Valid DatabaseTypeCreateRequest request) {
databaseTypeValidator.isValidUrlPattern(request.getUrlPattern()); databaseTypeValidator.isValidUrlPattern(request.getUrlPattern());
Integer id = databaseTypeService.create(request); Integer id = databaseTypeService.create(request);
@ -51,6 +52,7 @@ public class DatabaseTypeController {
@PatchMapping(Routes.DatabaseType.UPDATE) @PatchMapping(Routes.DatabaseType.UPDATE)
@Operation(module = Operation.Modules.DATABASE_TYPE, name = "更新数据库类型") @Operation(module = Operation.Modules.DATABASE_TYPE, name = "更新数据库类型")
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
public JsonData<Void> update(@RequestBody @Valid DatabaseTypeUpdateRequest request) { public JsonData<Void> update(@RequestBody @Valid DatabaseTypeUpdateRequest request) {
databaseTypeValidator.isValidUrlPattern(request.getUrlPattern()); databaseTypeValidator.isValidUrlPattern(request.getUrlPattern());
databaseTypeService.update(request); databaseTypeService.update(request);
@ -59,6 +61,7 @@ public class DatabaseTypeController {
@DeleteMapping(Routes.DatabaseType.DELETE_ONE) @DeleteMapping(Routes.DatabaseType.DELETE_ONE)
@Operation(module = Operation.Modules.DATABASE_TYPE, name = "删除数据库类型") @Operation(module = Operation.Modules.DATABASE_TYPE, name = "删除数据库类型")
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
public JsonData<Void> delete(@PathVariable Integer id) { public JsonData<Void> delete(@PathVariable Integer id) {
databaseTypeService.deleteById(id); databaseTypeService.deleteById(id);
return JsonData.ok(); return JsonData.ok();

13
api/src/main/java/com/databasir/api/validator/DatabaseTypeValidator.java

@ -1,23 +1,24 @@
package com.databasir.api.validator; package com.databasir.api.validator;
import com.databasir.core.domain.DomainErrors;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static com.databasir.core.domain.DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN;
@Component @Component
public class DatabaseTypeValidator { public class DatabaseTypeValidator {
public void isValidUrlPattern(String urlPattern) { public void isValidUrlPattern(String urlPattern) {
if (urlPattern == null) { if (urlPattern == null) {
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("url pattern 不能为空"); throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("url pattern 不能为空");
} }
if (!urlPattern.contains("{{jdbc.protocol}}")) { if (!urlPattern.contains("{{jdbc.protocol}}")) {
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{jdbc.protocol}}"); throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{jdbc.protocol}}");
} }
if (!urlPattern.contains("{{db.url}}")) { if (!urlPattern.contains("{{db.url}}")) {
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.url}}不能为空"); throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.url}}不能为空");
} }
if (!urlPattern.contains("{{db.name}}")) { if (!urlPattern.contains("{{db.schema}}") && !urlPattern.contains("{{db.name}}")) {
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.name}}不能为空"); throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("{{db.schema}} 和 {{db.name}} 至少设置一个");
} }
} }
} }

0
api/src/main/resources/static/css/898.edb95c8a.css → api/src/main/resources/static/css/395.edb95c8a.css

0
api/src/main/resources/static/css/506.82a2f213.css → api/src/main/resources/static/css/459.82a2f213.css

2
api/src/main/resources/static/index.html

@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><script defer="defer" type="module" src="/js/chunk-vendors.45746587.js"></script><script defer="defer" type="module" src="/js/app.21cfd672.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.54c3660b.js" nomodule></script><script defer="defer" src="/js/app-legacy.f867641a.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html> <!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><script defer="defer" type="module" src="/js/chunk-vendors.45746587.js"></script><script defer="defer" type="module" src="/js/app.a4b9bb20.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.54c3660b.js" nomodule></script><script defer="defer" src="/js/app-legacy.2527a373.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

4
api/src/main/resources/static/js/809-legacy.1f0d7d41.js → api/src/main/resources/static/js/117-legacy.72d604e3.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/117-legacy.72d604e3.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/269-legacy.b06c44d2.js → api/src/main/resources/static/js/269-legacy.1ed6e867.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269-legacy.1ed6e867.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269-legacy.b06c44d2.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269.3d925388.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/269.3d925388.js → api/src/main/resources/static/js/269.fb28ff39.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269.fb28ff39.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/306.836b767d.js.map

File diff suppressed because one or more lines are too long

6
api/src/main/resources/static/js/898-legacy.13f30c0d.js → api/src/main/resources/static/js/395-legacy.e525ab53.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/395-legacy.e525ab53.js.map

File diff suppressed because one or more lines are too long

6
api/src/main/resources/static/js/898.a81fbbe7.js → api/src/main/resources/static/js/395.f7b88568.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/395.f7b88568.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/459-legacy.5a5a02e8.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/459-legacy.5a5a02e8.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/459.22e837b8.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/459.22e837b8.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/506-legacy.5b373ce0.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/506-legacy.5b373ce0.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/506.128427e0.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/506.128427e0.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/306.836b767d.js → api/src/main/resources/static/js/564.07fcac27.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/564.07fcac27.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/809-legacy.1f0d7d41.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/898-legacy.13f30c0d.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/898.a81fbbe7.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/app-legacy.f867641a.js → api/src/main/resources/static/js/app-legacy.2527a373.js

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/app-legacy.f867641a.js.map → api/src/main/resources/static/js/app-legacy.2527a373.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/app.21cfd672.js → api/src/main/resources/static/js/app.a4b9bb20.js

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/app.21cfd672.js.map → api/src/main/resources/static/js/app.a4b9bb20.js.map

File diff suppressed because one or more lines are too long

15
core/src/main/java/com/databasir/core/domain/database/data/DatabaseTypeSimpleResponse.java

@ -0,0 +1,15 @@
package com.databasir.core.domain.database.data;
import lombok.Data;
@Data
public class DatabaseTypeSimpleResponse {
private String databaseType;
private String description;
private String urlPattern;
private String jdbcProtocol;
}

11
core/src/main/java/com/databasir/core/domain/database/service/DatabaseTypeService.java

@ -89,10 +89,17 @@ public class DatabaseTypeService {
}); });
} }
public List<String> listSimpleDatabaseTypes() { public List<DatabaseTypeSimpleResponse> listSimpleDatabaseTypes() {
return databaseTypeDao.selectAll() return databaseTypeDao.selectAll()
.stream() .stream()
.map(DatabaseTypePojo::getDatabaseType) .map(type -> {
DatabaseTypeSimpleResponse response = new DatabaseTypeSimpleResponse();
response.setDatabaseType(type.getDatabaseType());
response.setUrlPattern(type.getUrlPattern());
response.setDescription(type.getDescription());
response.setJdbcProtocol(type.getJdbcProtocol());
return response;
})
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

1
core/src/main/java/com/databasir/core/domain/document/converter/DocumentPojoConverter.java

@ -16,6 +16,7 @@ import java.util.stream.Collectors;
public interface DocumentPojoConverter extends BaseConverter { public interface DocumentPojoConverter extends BaseConverter {
@Mapping(target = "databaseName", source = "meta.databaseName") @Mapping(target = "databaseName", source = "meta.databaseName")
@Mapping(target = "schemaName", source = "meta.schemaName")
@Mapping(target = "isArchive", constant = "false") @Mapping(target = "isArchive", constant = "false")
DatabaseDocumentPojo toDatabasePojo(Integer projectId, DatabaseDocumentPojo toDatabasePojo(Integer projectId,
com.databasir.core.meta.data.DatabaseMeta meta, com.databasir.core.meta.data.DatabaseMeta meta,

2
core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentResponse.java

@ -19,6 +19,8 @@ public class DatabaseDocumentResponse {
private String databaseName; private String databaseName;
private String schemaName;
private String productName; private String productName;
private String productVersion; private String productVersion;

2
core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentSimpleResponse.java

@ -13,6 +13,8 @@ public class DatabaseDocumentSimpleResponse {
private String databaseName; private String databaseName;
private String schemaName;
private String productName; private String productName;
private String productVersion; private String productVersion;

2
core/src/main/java/com/databasir/core/domain/document/service/DocumentService.java

@ -89,7 +89,7 @@ public class DocumentService {
databasirConfig.setIgnoreTableNameRegex(jsonConverter.fromJson(rule.getIgnoreTableNameRegexArray())); databasirConfig.setIgnoreTableNameRegex(jsonConverter.fromJson(rule.getIgnoreTableNameRegexArray()));
databasirConfig.setIgnoreTableColumnNameRegex(jsonConverter.fromJson(rule.getIgnoreColumnNameRegexArray())); databasirConfig.setIgnoreTableColumnNameRegex(jsonConverter.fromJson(rule.getIgnoreColumnNameRegexArray()));
return Databasir.of(databasirConfig) return Databasir.of(databasirConfig)
.get(jdbcConnection, dataSource.getDatabaseName()) .get(jdbcConnection, dataSource.getDatabaseName(), dataSource.getSchemaName())
.orElseThrow(DomainErrors.DATABASE_META_NOT_FOUND::exception); .orElseThrow(DomainErrors.DATABASE_META_NOT_FOUND::exception);
} }

3
core/src/main/java/com/databasir/core/domain/project/data/ProjectCreateRequest.java

@ -40,6 +40,9 @@ public class ProjectCreateRequest {
@NotBlank @NotBlank
private String databaseName; private String databaseName;
@NotBlank
private String schemaName;
@NotBlank @NotBlank
private String databaseType; private String databaseType;

2
core/src/main/java/com/databasir/core/domain/project/data/ProjectDetailResponse.java

@ -34,6 +34,8 @@ public class ProjectDetailResponse {
private String databaseName; private String databaseName;
private String schemaName;
private String databaseType; private String databaseType;
private List<DataSourcePropertyValue> properties = new ArrayList<>(); private List<DataSourcePropertyValue> properties = new ArrayList<>();

6
core/src/main/java/com/databasir/core/domain/project/data/ProjectListCondition.java

@ -15,6 +15,8 @@ public class ProjectListCondition {
private String databaseNameContains; private String databaseNameContains;
private String schemaNameContains;
private String databaseType; private String databaseType;
private Integer groupId; private Integer groupId;
@ -29,6 +31,10 @@ public class ProjectListCondition {
Condition condition = Tables.DATA_SOURCE.DATABASE_NAME.contains(databaseNameContains); Condition condition = Tables.DATA_SOURCE.DATABASE_NAME.contains(databaseNameContains);
conditions.add(condition); conditions.add(condition);
} }
if (schemaNameContains != null) {
Condition condition = Tables.DATA_SOURCE.SCHEMA_NAME.contains(schemaNameContains);
conditions.add(condition);
}
if (databaseType != null) { if (databaseType != null) {
Condition condition = Tables.DATA_SOURCE.DATABASE_TYPE.eq(databaseType); Condition condition = Tables.DATA_SOURCE.DATABASE_TYPE.eq(databaseType);
conditions.add(condition); conditions.add(condition);

2
core/src/main/java/com/databasir/core/domain/project/data/ProjectSimpleResponse.java

@ -15,6 +15,8 @@ public class ProjectSimpleResponse {
private String databaseName; private String databaseName;
private String schemaName;
private String databaseType; private String databaseType;
private Boolean isAutoSync; private Boolean isAutoSync;

3
core/src/main/java/com/databasir/core/domain/project/data/ProjectTestConnectionRequest.java

@ -22,6 +22,9 @@ public class ProjectTestConnectionRequest {
@NotBlank @NotBlank
private String databaseName; private String databaseName;
@NotBlank
private String schemaName;
@NotBlank @NotBlank
private String databaseType; private String databaseType;

3
core/src/main/java/com/databasir/core/domain/project/data/ProjectUpdateRequest.java

@ -39,6 +39,9 @@ public class ProjectUpdateRequest {
@NotBlank @NotBlank
private String databaseName; private String databaseName;
@NotBlank
private String schemaName;
@NotBlank @NotBlank
private String databaseType; private String databaseType;

1
core/src/main/java/com/databasir/core/domain/project/service/ProjectService.java

@ -169,6 +169,7 @@ public class ProjectService {
password, password,
request.getUrl(), request.getUrl(),
request.getDatabaseName(), request.getDatabaseName(),
request.getSchemaName(),
request.getDatabaseType(), request.getDatabaseType(),
properties); properties);
} }

3
core/src/main/java/com/databasir/core/infrastructure/connection/CustomDatabaseConnectionFactory.java

@ -78,7 +78,8 @@ public class CustomDatabaseConnectionFactory implements DatabaseConnectionFactor
String urlPattern = type.getUrlPattern(); String urlPattern = type.getUrlPattern();
String jdbcUrl = urlPattern.replace("{{jdbc.protocol}}", type.getJdbcProtocol()) String jdbcUrl = urlPattern.replace("{{jdbc.protocol}}", type.getJdbcProtocol())
.replace("{{db.url}}", context.getUrl()) .replace("{{db.url}}", context.getUrl())
.replace("{{db.name}}", context.getSchema()); .replace("{{db.name}}", context.getDatabaseName())
.replace("{{db.schema}}", context.getSchemaName());
Properties info = new Properties(); Properties info = new Properties();
info.put("user", context.getUsername()); info.put("user", context.getUsername());
info.put("password", context.getPassword()); info.put("password", context.getPassword());

4
core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionFactory.java

@ -25,7 +25,9 @@ public interface DatabaseConnectionFactory {
private String url; private String url;
private String schema; private String databaseName;
private String schemaName;
private Properties properties; private Properties properties;
} }

7
core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionService.java

@ -36,7 +36,8 @@ public class DatabaseConnectionService {
.username(username) .username(username)
.password(password) .password(password)
.url(url) .url(url)
.schema(dataSource.getDatabaseName()) .databaseName(dataSource.getDatabaseName())
.schemaName(dataSource.getSchemaName())
.properties(info) .properties(info)
.databaseType(dataSource.getDatabaseType()) .databaseType(dataSource.getDatabaseType())
.build(); .build();
@ -54,6 +55,7 @@ public class DatabaseConnectionService {
String password, String password,
String url, String url,
String databaseName, String databaseName,
String schemaName,
String databaseType, String databaseType,
Properties properties) { Properties properties) {
try { try {
@ -61,7 +63,8 @@ public class DatabaseConnectionService {
.username(username) .username(username)
.password(password) .password(password)
.url(url) .url(url)
.schema(databaseName) .databaseName(databaseName)
.schemaName(schemaName)
.properties(properties) .properties(properties)
.databaseType(databaseType) .databaseType(databaseType)
.build(); .build();

2
core/src/main/java/com/databasir/core/infrastructure/connection/MysqlDatabaseConnectionFactory.java

@ -29,7 +29,7 @@ public class MysqlDatabaseConnectionFactory implements DatabaseConnectionFactory
info.put("user", context.getUsername()); info.put("user", context.getUsername());
info.put("password", context.getPassword()); info.put("password", context.getPassword());
info.putAll(context.getProperties()); info.putAll(context.getProperties());
String jdbcUrl = "jdbc:mysql://" + context.getUrl() + "/" + context.getSchema(); String jdbcUrl = "jdbc:mysql://" + context.getUrl() + "/" + context.getDatabaseName();
return DriverManager.getConnection(jdbcUrl, info); return DriverManager.getConnection(jdbcUrl, info);
} }

2
core/src/main/java/com/databasir/core/infrastructure/connection/PostgresqlDatabaseConnectionFactory.java

@ -29,7 +29,7 @@ public class PostgresqlDatabaseConnectionFactory implements DatabaseConnectionFa
info.put("user", context.getUsername()); info.put("user", context.getUsername());
info.put("password", context.getPassword()); info.put("password", context.getPassword());
info.putAll(context.getProperties()); info.putAll(context.getProperties());
String jdbcUrl = "jdbc:postgresql://" + context.getUrl() + "/" + context.getSchema(); String jdbcUrl = "jdbc:postgresql://" + context.getUrl() + "/" + context.getDatabaseName();
return DriverManager.getConnection(jdbcUrl, info); return DriverManager.getConnection(jdbcUrl, info);
} }
} }

15
dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSource.java

@ -17,7 +17,7 @@ import org.jooq.ForeignKey;
import org.jooq.Identity; import org.jooq.Identity;
import org.jooq.Name; import org.jooq.Name;
import org.jooq.Record; import org.jooq.Record;
import org.jooq.Row9; import org.jooq.Row10;
import org.jooq.Schema; import org.jooq.Schema;
import org.jooq.Table; import org.jooq.Table;
import org.jooq.TableField; import org.jooq.TableField;
@ -62,7 +62,12 @@ public class DataSource extends TableImpl<DataSourceRecord> {
/** /**
* The column <code>databasir.data_source.database_name</code>. * The column <code>databasir.data_source.database_name</code>.
*/ */
public final TableField<DataSourceRecord, String> DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.VARCHAR(512).nullable(false), this, ""); public final TableField<DataSourceRecord, String> DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
/**
* The column <code>databasir.data_source.schema_name</code>.
*/
public final TableField<DataSourceRecord, String> SCHEMA_NAME = createField(DSL.name("schema_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
/** /**
* The column <code>databasir.data_source.database_type</code>. * The column <code>databasir.data_source.database_type</code>.
@ -174,11 +179,11 @@ public class DataSource extends TableImpl<DataSourceRecord> {
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Row9 type methods // Row10 type methods
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Override @Override
public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() { public Row10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow(); return (Row10) super.fieldsRow();
} }
} }

33
dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocument.java

@ -8,27 +8,15 @@ import com.databasir.dao.Databasir;
import com.databasir.dao.Indexes; import com.databasir.dao.Indexes;
import com.databasir.dao.Keys; import com.databasir.dao.Keys;
import com.databasir.dao.tables.records.DatabaseDocumentRecord; import com.databasir.dao.tables.records.DatabaseDocumentRecord;
import org.jooq.*;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Identity;
import org.jooq.Index;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Row9;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;
/** /**
* This class is generated by jOOQ. * This class is generated by jOOQ.
@ -64,7 +52,12 @@ public class DatabaseDocument extends TableImpl<DatabaseDocumentRecord> {
/** /**
* The column <code>databasir.database_document.database_name</code>. * The column <code>databasir.database_document.database_name</code>.
*/ */
public final TableField<DatabaseDocumentRecord, String> DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.CLOB.nullable(false), this, ""); public final TableField<DatabaseDocumentRecord, String> DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
/**
* The column <code>databasir.database_document.schema_name</code>.
*/
public final TableField<DatabaseDocumentRecord, String> SCHEMA_NAME = createField(DSL.name("schema_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
/** /**
* The column <code>databasir.database_document.product_name</code>. * The column <code>databasir.database_document.product_name</code>.
@ -178,11 +171,11 @@ public class DatabaseDocument extends TableImpl<DatabaseDocumentRecord> {
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Row9 type methods // Row10 type methods
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Override @Override
public Row9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() { public Row10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow(); return (Row10) super.fieldsRow();
} }
} }

19
dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePojo.java

@ -19,6 +19,7 @@ public class DataSourcePojo implements Serializable {
private Integer id; private Integer id;
private Integer projectId; private Integer projectId;
private String databaseName; private String databaseName;
private String schemaName;
private String databaseType; private String databaseType;
private String url; private String url;
private String username; private String username;
@ -32,6 +33,7 @@ public class DataSourcePojo implements Serializable {
this.id = value.id; this.id = value.id;
this.projectId = value.projectId; this.projectId = value.projectId;
this.databaseName = value.databaseName; this.databaseName = value.databaseName;
this.schemaName = value.schemaName;
this.databaseType = value.databaseType; this.databaseType = value.databaseType;
this.url = value.url; this.url = value.url;
this.username = value.username; this.username = value.username;
@ -44,6 +46,7 @@ public class DataSourcePojo implements Serializable {
Integer id, Integer id,
Integer projectId, Integer projectId,
String databaseName, String databaseName,
String schemaName,
String databaseType, String databaseType,
String url, String url,
String username, String username,
@ -54,6 +57,7 @@ public class DataSourcePojo implements Serializable {
this.id = id; this.id = id;
this.projectId = projectId; this.projectId = projectId;
this.databaseName = databaseName; this.databaseName = databaseName;
this.schemaName = schemaName;
this.databaseType = databaseType; this.databaseType = databaseType;
this.url = url; this.url = url;
this.username = username; this.username = username;
@ -104,6 +108,20 @@ public class DataSourcePojo implements Serializable {
this.databaseName = databaseName; this.databaseName = databaseName;
} }
/**
* Getter for <code>databasir.data_source.schema_name</code>.
*/
public String getSchemaName() {
return this.schemaName;
}
/**
* Setter for <code>databasir.data_source.schema_name</code>.
*/
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
/** /**
* Getter for <code>databasir.data_source.database_type</code>. * Getter for <code>databasir.data_source.database_type</code>.
*/ */
@ -195,6 +213,7 @@ public class DataSourcePojo implements Serializable {
sb.append(id); sb.append(id);
sb.append(", ").append(projectId); sb.append(", ").append(projectId);
sb.append(", ").append(databaseName); sb.append(", ").append(databaseName);
sb.append(", ").append(schemaName);
sb.append(", ").append(databaseType); sb.append(", ").append(databaseType);
sb.append(", ").append(url); sb.append(", ").append(url);
sb.append(", ").append(username); sb.append(", ").append(username);

19
dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentPojo.java

@ -19,6 +19,7 @@ public class DatabaseDocumentPojo implements Serializable {
private Integer id; private Integer id;
private Integer projectId; private Integer projectId;
private String databaseName; private String databaseName;
private String schemaName;
private String productName; private String productName;
private String productVersion; private String productVersion;
private Long version; private Long version;
@ -32,6 +33,7 @@ public class DatabaseDocumentPojo implements Serializable {
this.id = value.id; this.id = value.id;
this.projectId = value.projectId; this.projectId = value.projectId;
this.databaseName = value.databaseName; this.databaseName = value.databaseName;
this.schemaName = value.schemaName;
this.productName = value.productName; this.productName = value.productName;
this.productVersion = value.productVersion; this.productVersion = value.productVersion;
this.version = value.version; this.version = value.version;
@ -44,6 +46,7 @@ public class DatabaseDocumentPojo implements Serializable {
Integer id, Integer id,
Integer projectId, Integer projectId,
String databaseName, String databaseName,
String schemaName,
String productName, String productName,
String productVersion, String productVersion,
Long version, Long version,
@ -54,6 +57,7 @@ public class DatabaseDocumentPojo implements Serializable {
this.id = id; this.id = id;
this.projectId = projectId; this.projectId = projectId;
this.databaseName = databaseName; this.databaseName = databaseName;
this.schemaName = schemaName;
this.productName = productName; this.productName = productName;
this.productVersion = productVersion; this.productVersion = productVersion;
this.version = version; this.version = version;
@ -104,6 +108,20 @@ public class DatabaseDocumentPojo implements Serializable {
this.databaseName = databaseName; this.databaseName = databaseName;
} }
/**
* Getter for <code>databasir.database_document.schema_name</code>.
*/
public String getSchemaName() {
return this.schemaName;
}
/**
* Setter for <code>databasir.database_document.schema_name</code>.
*/
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
/** /**
* Getter for <code>databasir.database_document.product_name</code>. * Getter for <code>databasir.database_document.product_name</code>.
*/ */
@ -195,6 +213,7 @@ public class DatabaseDocumentPojo implements Serializable {
sb.append(id); sb.append(id);
sb.append(", ").append(projectId); sb.append(", ").append(projectId);
sb.append(", ").append(databaseName); sb.append(", ").append(databaseName);
sb.append(", ").append(schemaName);
sb.append(", ").append(productName); sb.append(", ").append(productName);
sb.append(", ").append(productVersion); sb.append(", ").append(productVersion);
sb.append(", ").append(version); sb.append(", ").append(version);

122
dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourceRecord.java

@ -11,8 +11,8 @@ import java.time.LocalDateTime;
import org.jooq.Field; import org.jooq.Field;
import org.jooq.Record1; import org.jooq.Record1;
import org.jooq.Record9; import org.jooq.Record10;
import org.jooq.Row9; import org.jooq.Row10;
import org.jooq.impl.UpdatableRecordImpl; import org.jooq.impl.UpdatableRecordImpl;
@ -20,7 +20,7 @@ import org.jooq.impl.UpdatableRecordImpl;
* This class is generated by jOOQ. * This class is generated by jOOQ.
*/ */
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) @SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> implements Record9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> { public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> implements Record10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -66,88 +66,102 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
return (String) get(2); return (String) get(2);
} }
/**
* Setter for <code>databasir.data_source.schema_name</code>.
*/
public void setSchemaName(String value) {
set(3, value);
}
/**
* Getter for <code>databasir.data_source.schema_name</code>.
*/
public String getSchemaName() {
return (String) get(3);
}
/** /**
* Setter for <code>databasir.data_source.database_type</code>. * Setter for <code>databasir.data_source.database_type</code>.
*/ */
public void setDatabaseType(String value) { public void setDatabaseType(String value) {
set(3, value); set(4, value);
} }
/** /**
* Getter for <code>databasir.data_source.database_type</code>. * Getter for <code>databasir.data_source.database_type</code>.
*/ */
public String getDatabaseType() { public String getDatabaseType() {
return (String) get(3); return (String) get(4);
} }
/** /**
* Setter for <code>databasir.data_source.url</code>. * Setter for <code>databasir.data_source.url</code>.
*/ */
public void setUrl(String value) { public void setUrl(String value) {
set(4, value); set(5, value);
} }
/** /**
* Getter for <code>databasir.data_source.url</code>. * Getter for <code>databasir.data_source.url</code>.
*/ */
public String getUrl() { public String getUrl() {
return (String) get(4); return (String) get(5);
} }
/** /**
* Setter for <code>databasir.data_source.username</code>. * Setter for <code>databasir.data_source.username</code>.
*/ */
public void setUsername(String value) { public void setUsername(String value) {
set(5, value); set(6, value);
} }
/** /**
* Getter for <code>databasir.data_source.username</code>. * Getter for <code>databasir.data_source.username</code>.
*/ */
public String getUsername() { public String getUsername() {
return (String) get(5); return (String) get(6);
} }
/** /**
* Setter for <code>databasir.data_source.password</code>. * Setter for <code>databasir.data_source.password</code>.
*/ */
public void setPassword(String value) { public void setPassword(String value) {
set(6, value); set(7, value);
} }
/** /**
* Getter for <code>databasir.data_source.password</code>. * Getter for <code>databasir.data_source.password</code>.
*/ */
public String getPassword() { public String getPassword() {
return (String) get(6); return (String) get(7);
} }
/** /**
* Setter for <code>databasir.data_source.update_at</code>. * Setter for <code>databasir.data_source.update_at</code>.
*/ */
public void setUpdateAt(LocalDateTime value) { public void setUpdateAt(LocalDateTime value) {
set(7, value); set(8, value);
} }
/** /**
* Getter for <code>databasir.data_source.update_at</code>. * Getter for <code>databasir.data_source.update_at</code>.
*/ */
public LocalDateTime getUpdateAt() { public LocalDateTime getUpdateAt() {
return (LocalDateTime) get(7); return (LocalDateTime) get(8);
} }
/** /**
* Setter for <code>databasir.data_source.create_at</code>. * Setter for <code>databasir.data_source.create_at</code>.
*/ */
public void setCreateAt(LocalDateTime value) { public void setCreateAt(LocalDateTime value) {
set(8, value); set(9, value);
} }
/** /**
* Getter for <code>databasir.data_source.create_at</code>. * Getter for <code>databasir.data_source.create_at</code>.
*/ */
public LocalDateTime getCreateAt() { public LocalDateTime getCreateAt() {
return (LocalDateTime) get(8); return (LocalDateTime) get(9);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -160,17 +174,17 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Record9 type implementation // Record10 type implementation
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Override @Override
public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() { public Row10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow(); return (Row10) super.fieldsRow();
} }
@Override @Override
public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() { public Row10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() {
return (Row9) super.valuesRow(); return (Row10) super.valuesRow();
} }
@Override @Override
@ -190,31 +204,36 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override @Override
public Field<String> field4() { public Field<String> field4() {
return DataSource.DATA_SOURCE.DATABASE_TYPE; return DataSource.DATA_SOURCE.SCHEMA_NAME;
} }
@Override @Override
public Field<String> field5() { public Field<String> field5() {
return DataSource.DATA_SOURCE.URL; return DataSource.DATA_SOURCE.DATABASE_TYPE;
} }
@Override @Override
public Field<String> field6() { public Field<String> field6() {
return DataSource.DATA_SOURCE.USERNAME; return DataSource.DATA_SOURCE.URL;
} }
@Override @Override
public Field<String> field7() { public Field<String> field7() {
return DataSource.DATA_SOURCE.USERNAME;
}
@Override
public Field<String> field8() {
return DataSource.DATA_SOURCE.PASSWORD; return DataSource.DATA_SOURCE.PASSWORD;
} }
@Override @Override
public Field<LocalDateTime> field8() { public Field<LocalDateTime> field9() {
return DataSource.DATA_SOURCE.UPDATE_AT; return DataSource.DATA_SOURCE.UPDATE_AT;
} }
@Override @Override
public Field<LocalDateTime> field9() { public Field<LocalDateTime> field10() {
return DataSource.DATA_SOURCE.CREATE_AT; return DataSource.DATA_SOURCE.CREATE_AT;
} }
@ -235,31 +254,36 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override @Override
public String component4() { public String component4() {
return getDatabaseType(); return getSchemaName();
} }
@Override @Override
public String component5() { public String component5() {
return getUrl(); return getDatabaseType();
} }
@Override @Override
public String component6() { public String component6() {
return getUsername(); return getUrl();
} }
@Override @Override
public String component7() { public String component7() {
return getUsername();
}
@Override
public String component8() {
return getPassword(); return getPassword();
} }
@Override @Override
public LocalDateTime component8() { public LocalDateTime component9() {
return getUpdateAt(); return getUpdateAt();
} }
@Override @Override
public LocalDateTime component9() { public LocalDateTime component10() {
return getCreateAt(); return getCreateAt();
} }
@ -280,31 +304,36 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override @Override
public String value4() { public String value4() {
return getDatabaseType(); return getSchemaName();
} }
@Override @Override
public String value5() { public String value5() {
return getUrl(); return getDatabaseType();
} }
@Override @Override
public String value6() { public String value6() {
return getUsername(); return getUrl();
} }
@Override @Override
public String value7() { public String value7() {
return getUsername();
}
@Override
public String value8() {
return getPassword(); return getPassword();
} }
@Override @Override
public LocalDateTime value8() { public LocalDateTime value9() {
return getUpdateAt(); return getUpdateAt();
} }
@Override @Override
public LocalDateTime value9() { public LocalDateTime value10() {
return getCreateAt(); return getCreateAt();
} }
@ -328,42 +357,48 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override @Override
public DataSourceRecord value4(String value) { public DataSourceRecord value4(String value) {
setDatabaseType(value); setSchemaName(value);
return this; return this;
} }
@Override @Override
public DataSourceRecord value5(String value) { public DataSourceRecord value5(String value) {
setUrl(value); setDatabaseType(value);
return this; return this;
} }
@Override @Override
public DataSourceRecord value6(String value) { public DataSourceRecord value6(String value) {
setUsername(value); setUrl(value);
return this; return this;
} }
@Override @Override
public DataSourceRecord value7(String value) { public DataSourceRecord value7(String value) {
setUsername(value);
return this;
}
@Override
public DataSourceRecord value8(String value) {
setPassword(value); setPassword(value);
return this; return this;
} }
@Override @Override
public DataSourceRecord value8(LocalDateTime value) { public DataSourceRecord value9(LocalDateTime value) {
setUpdateAt(value); setUpdateAt(value);
return this; return this;
} }
@Override @Override
public DataSourceRecord value9(LocalDateTime value) { public DataSourceRecord value10(LocalDateTime value) {
setCreateAt(value); setCreateAt(value);
return this; return this;
} }
@Override @Override
public DataSourceRecord values(Integer value1, Integer value2, String value3, String value4, String value5, String value6, String value7, LocalDateTime value8, LocalDateTime value9) { public DataSourceRecord values(Integer value1, Integer value2, String value3, String value4, String value5, String value6, String value7, String value8, LocalDateTime value9, LocalDateTime value10) {
value1(value1); value1(value1);
value2(value2); value2(value2);
value3(value3); value3(value3);
@ -373,6 +408,7 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
value7(value7); value7(value7);
value8(value8); value8(value8);
value9(value9); value9(value9);
value10(value10);
return this; return this;
} }
@ -390,12 +426,13 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
/** /**
* Create a detached, initialised DataSourceRecord * Create a detached, initialised DataSourceRecord
*/ */
public DataSourceRecord(Integer id, Integer projectId, String databaseName, String databaseType, String url, String username, String password, LocalDateTime updateAt, LocalDateTime createAt) { public DataSourceRecord(Integer id, Integer projectId, String databaseName, String schemaName, String databaseType, String url, String username, String password, LocalDateTime updateAt, LocalDateTime createAt) {
super(DataSource.DATA_SOURCE); super(DataSource.DATA_SOURCE);
setId(id); setId(id);
setProjectId(projectId); setProjectId(projectId);
setDatabaseName(databaseName); setDatabaseName(databaseName);
setSchemaName(schemaName);
setDatabaseType(databaseType); setDatabaseType(databaseType);
setUrl(url); setUrl(url);
setUsername(username); setUsername(username);
@ -414,6 +451,7 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
setId(value.getId()); setId(value.getId());
setProjectId(value.getProjectId()); setProjectId(value.getProjectId());
setDatabaseName(value.getDatabaseName()); setDatabaseName(value.getDatabaseName());
setSchemaName(value.getSchemaName());
setDatabaseType(value.getDatabaseType()); setDatabaseType(value.getDatabaseType());
setUrl(value.getUrl()); setUrl(value.getUrl());
setUsername(value.getUsername()); setUsername(value.getUsername());

122
dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentRecord.java

@ -11,8 +11,8 @@ import java.time.LocalDateTime;
import org.jooq.Field; import org.jooq.Field;
import org.jooq.Record1; import org.jooq.Record1;
import org.jooq.Record9; import org.jooq.Record10;
import org.jooq.Row9; import org.jooq.Row10;
import org.jooq.impl.UpdatableRecordImpl; import org.jooq.impl.UpdatableRecordImpl;
@ -20,7 +20,7 @@ import org.jooq.impl.UpdatableRecordImpl;
* This class is generated by jOOQ. * This class is generated by jOOQ.
*/ */
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) @SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocumentRecord> implements Record9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> { public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocumentRecord> implements Record10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -66,88 +66,102 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
return (String) get(2); return (String) get(2);
} }
/**
* Setter for <code>databasir.database_document.schema_name</code>.
*/
public void setSchemaName(String value) {
set(3, value);
}
/**
* Getter for <code>databasir.database_document.schema_name</code>.
*/
public String getSchemaName() {
return (String) get(3);
}
/** /**
* Setter for <code>databasir.database_document.product_name</code>. * Setter for <code>databasir.database_document.product_name</code>.
*/ */
public void setProductName(String value) { public void setProductName(String value) {
set(3, value); set(4, value);
} }
/** /**
* Getter for <code>databasir.database_document.product_name</code>. * Getter for <code>databasir.database_document.product_name</code>.
*/ */
public String getProductName() { public String getProductName() {
return (String) get(3); return (String) get(4);
} }
/** /**
* Setter for <code>databasir.database_document.product_version</code>. * Setter for <code>databasir.database_document.product_version</code>.
*/ */
public void setProductVersion(String value) { public void setProductVersion(String value) {
set(4, value); set(5, value);
} }
/** /**
* Getter for <code>databasir.database_document.product_version</code>. * Getter for <code>databasir.database_document.product_version</code>.
*/ */
public String getProductVersion() { public String getProductVersion() {
return (String) get(4); return (String) get(5);
} }
/** /**
* Setter for <code>databasir.database_document.version</code>. * Setter for <code>databasir.database_document.version</code>.
*/ */
public void setVersion(Long value) { public void setVersion(Long value) {
set(5, value); set(6, value);
} }
/** /**
* Getter for <code>databasir.database_document.version</code>. * Getter for <code>databasir.database_document.version</code>.
*/ */
public Long getVersion() { public Long getVersion() {
return (Long) get(5); return (Long) get(6);
} }
/** /**
* Setter for <code>databasir.database_document.is_archive</code>. * Setter for <code>databasir.database_document.is_archive</code>.
*/ */
public void setIsArchive(Boolean value) { public void setIsArchive(Boolean value) {
set(6, value); set(7, value);
} }
/** /**
* Getter for <code>databasir.database_document.is_archive</code>. * Getter for <code>databasir.database_document.is_archive</code>.
*/ */
public Boolean getIsArchive() { public Boolean getIsArchive() {
return (Boolean) get(6); return (Boolean) get(7);
} }
/** /**
* Setter for <code>databasir.database_document.update_at</code>. * Setter for <code>databasir.database_document.update_at</code>.
*/ */
public void setUpdateAt(LocalDateTime value) { public void setUpdateAt(LocalDateTime value) {
set(7, value); set(8, value);
} }
/** /**
* Getter for <code>databasir.database_document.update_at</code>. * Getter for <code>databasir.database_document.update_at</code>.
*/ */
public LocalDateTime getUpdateAt() { public LocalDateTime getUpdateAt() {
return (LocalDateTime) get(7); return (LocalDateTime) get(8);
} }
/** /**
* Setter for <code>databasir.database_document.create_at</code>. * Setter for <code>databasir.database_document.create_at</code>.
*/ */
public void setCreateAt(LocalDateTime value) { public void setCreateAt(LocalDateTime value) {
set(8, value); set(9, value);
} }
/** /**
* Getter for <code>databasir.database_document.create_at</code>. * Getter for <code>databasir.database_document.create_at</code>.
*/ */
public LocalDateTime getCreateAt() { public LocalDateTime getCreateAt() {
return (LocalDateTime) get(8); return (LocalDateTime) get(9);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -160,17 +174,17 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Record9 type implementation // Record10 type implementation
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Override @Override
public Row9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() { public Row10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow(); return (Row10) super.fieldsRow();
} }
@Override @Override
public Row9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> valuesRow() { public Row10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> valuesRow() {
return (Row9) super.valuesRow(); return (Row10) super.valuesRow();
} }
@Override @Override
@ -190,31 +204,36 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override @Override
public Field<String> field4() { public Field<String> field4() {
return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_NAME; return DatabaseDocument.DATABASE_DOCUMENT.SCHEMA_NAME;
} }
@Override @Override
public Field<String> field5() { public Field<String> field5() {
return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_NAME;
}
@Override
public Field<String> field6() {
return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_VERSION; return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_VERSION;
} }
@Override @Override
public Field<Long> field6() { public Field<Long> field7() {
return DatabaseDocument.DATABASE_DOCUMENT.VERSION; return DatabaseDocument.DATABASE_DOCUMENT.VERSION;
} }
@Override @Override
public Field<Boolean> field7() { public Field<Boolean> field8() {
return DatabaseDocument.DATABASE_DOCUMENT.IS_ARCHIVE; return DatabaseDocument.DATABASE_DOCUMENT.IS_ARCHIVE;
} }
@Override @Override
public Field<LocalDateTime> field8() { public Field<LocalDateTime> field9() {
return DatabaseDocument.DATABASE_DOCUMENT.UPDATE_AT; return DatabaseDocument.DATABASE_DOCUMENT.UPDATE_AT;
} }
@Override @Override
public Field<LocalDateTime> field9() { public Field<LocalDateTime> field10() {
return DatabaseDocument.DATABASE_DOCUMENT.CREATE_AT; return DatabaseDocument.DATABASE_DOCUMENT.CREATE_AT;
} }
@ -235,31 +254,36 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override @Override
public String component4() { public String component4() {
return getProductName(); return getSchemaName();
} }
@Override @Override
public String component5() { public String component5() {
return getProductName();
}
@Override
public String component6() {
return getProductVersion(); return getProductVersion();
} }
@Override @Override
public Long component6() { public Long component7() {
return getVersion(); return getVersion();
} }
@Override @Override
public Boolean component7() { public Boolean component8() {
return getIsArchive(); return getIsArchive();
} }
@Override @Override
public LocalDateTime component8() { public LocalDateTime component9() {
return getUpdateAt(); return getUpdateAt();
} }
@Override @Override
public LocalDateTime component9() { public LocalDateTime component10() {
return getCreateAt(); return getCreateAt();
} }
@ -280,31 +304,36 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override @Override
public String value4() { public String value4() {
return getProductName(); return getSchemaName();
} }
@Override @Override
public String value5() { public String value5() {
return getProductName();
}
@Override
public String value6() {
return getProductVersion(); return getProductVersion();
} }
@Override @Override
public Long value6() { public Long value7() {
return getVersion(); return getVersion();
} }
@Override @Override
public Boolean value7() { public Boolean value8() {
return getIsArchive(); return getIsArchive();
} }
@Override @Override
public LocalDateTime value8() { public LocalDateTime value9() {
return getUpdateAt(); return getUpdateAt();
} }
@Override @Override
public LocalDateTime value9() { public LocalDateTime value10() {
return getCreateAt(); return getCreateAt();
} }
@ -328,42 +357,48 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override @Override
public DatabaseDocumentRecord value4(String value) { public DatabaseDocumentRecord value4(String value) {
setProductName(value); setSchemaName(value);
return this; return this;
} }
@Override @Override
public DatabaseDocumentRecord value5(String value) { public DatabaseDocumentRecord value5(String value) {
setProductName(value);
return this;
}
@Override
public DatabaseDocumentRecord value6(String value) {
setProductVersion(value); setProductVersion(value);
return this; return this;
} }
@Override @Override
public DatabaseDocumentRecord value6(Long value) { public DatabaseDocumentRecord value7(Long value) {
setVersion(value); setVersion(value);
return this; return this;
} }
@Override @Override
public DatabaseDocumentRecord value7(Boolean value) { public DatabaseDocumentRecord value8(Boolean value) {
setIsArchive(value); setIsArchive(value);
return this; return this;
} }
@Override @Override
public DatabaseDocumentRecord value8(LocalDateTime value) { public DatabaseDocumentRecord value9(LocalDateTime value) {
setUpdateAt(value); setUpdateAt(value);
return this; return this;
} }
@Override @Override
public DatabaseDocumentRecord value9(LocalDateTime value) { public DatabaseDocumentRecord value10(LocalDateTime value) {
setCreateAt(value); setCreateAt(value);
return this; return this;
} }
@Override @Override
public DatabaseDocumentRecord values(Integer value1, Integer value2, String value3, String value4, String value5, Long value6, Boolean value7, LocalDateTime value8, LocalDateTime value9) { public DatabaseDocumentRecord values(Integer value1, Integer value2, String value3, String value4, String value5, String value6, Long value7, Boolean value8, LocalDateTime value9, LocalDateTime value10) {
value1(value1); value1(value1);
value2(value2); value2(value2);
value3(value3); value3(value3);
@ -373,6 +408,7 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
value7(value7); value7(value7);
value8(value8); value8(value8);
value9(value9); value9(value9);
value10(value10);
return this; return this;
} }
@ -390,12 +426,13 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
/** /**
* Create a detached, initialised DatabaseDocumentRecord * Create a detached, initialised DatabaseDocumentRecord
*/ */
public DatabaseDocumentRecord(Integer id, Integer projectId, String databaseName, String productName, String productVersion, Long version, Boolean isArchive, LocalDateTime updateAt, LocalDateTime createAt) { public DatabaseDocumentRecord(Integer id, Integer projectId, String databaseName, String schemaName, String productName, String productVersion, Long version, Boolean isArchive, LocalDateTime updateAt, LocalDateTime createAt) {
super(DatabaseDocument.DATABASE_DOCUMENT); super(DatabaseDocument.DATABASE_DOCUMENT);
setId(id); setId(id);
setProjectId(projectId); setProjectId(projectId);
setDatabaseName(databaseName); setDatabaseName(databaseName);
setSchemaName(schemaName);
setProductName(productName); setProductName(productName);
setProductVersion(productVersion); setProductVersion(productVersion);
setVersion(version); setVersion(version);
@ -414,6 +451,7 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
setId(value.getId()); setId(value.getId());
setProjectId(value.getProjectId()); setProjectId(value.getProjectId());
setDatabaseName(value.getDatabaseName()); setDatabaseName(value.getDatabaseName());
setSchemaName(value.getSchemaName());
setProductName(value.getProductName()); setProductName(value.getProductName());
setProductVersion(value.getProductVersion()); setProductVersion(value.getProductVersion());
setVersion(value.getVersion()); setVersion(value.getVersion());

20
dao/src/main/resources/db/migration/V1__init.sql

@ -93,7 +93,8 @@ CREATE TABLE IF NOT EXISTS `data_source`
( (
id INT PRIMARY KEY AUTO_INCREMENT, id INT PRIMARY KEY AUTO_INCREMENT,
project_id INT NOT NULL, project_id INT NOT NULL,
database_name VARCHAR(512) NOT NULL, database_name VARCHAR(255) NOT NULL,
schema_name VARCHAR(255) NOT NULL,
database_type VARCHAR(255) NOT NULL, database_type VARCHAR(255) NOT NULL,
url TEXT NOT NULL, url TEXT NOT NULL,
username TEXT NOT NULL, username TEXT NOT NULL,
@ -118,14 +119,15 @@ CREATE TABLE IF NOT EXISTS `data_source_property`
CREATE TABLE IF NOT EXISTS database_document CREATE TABLE IF NOT EXISTS database_document
( (
id INT PRIMARY KEY AUTO_INCREMENT, id INT PRIMARY KEY AUTO_INCREMENT,
project_id INT NOT NULL, project_id INT NOT NULL,
database_name TEXT NOT NULL, database_name VARCHAR(255) NOT NULL,
product_name TEXT NOT NULL, schema_name VARCHAR(255) NOT NULL,
product_version TEXT NOT NULL, product_name TEXT NOT NULL,
version BIGINT NOT NULL DEFAULT 1, product_version TEXT NOT NULL,
is_archive BOOLEAN NOT NULL DEFAULT FALSE, version BIGINT NOT NULL DEFAULT 1,
update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, is_archive BOOLEAN NOT NULL DEFAULT FALSE,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX idx_project_id (project_id) INDEX idx_project_id (project_id)
) CHARSET utf8mb4 ) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci; COLLATE utf8mb4_unicode_ci;

3
plugin/src/main/java/com/databasir/core/Databasir.java

@ -20,9 +20,10 @@ public class Databasir {
private final DatabasirConfig config; private final DatabasirConfig config;
public Optional<DatabaseMeta> get(Connection connection, String databaseName) { public Optional<DatabaseMeta> get(Connection connection, String databaseName, String schemaName) {
Condition condition = Condition.builder() Condition condition = Condition.builder()
.databaseName(databaseName) .databaseName(databaseName)
.schemaName(schemaName)
.ignoreTableNameRegex(config.getIgnoreTableNameRegex()) .ignoreTableNameRegex(config.getIgnoreTableNameRegex())
.ignoreTableColumnNameRegex(config.getIgnoreTableColumnNameRegex()) .ignoreTableColumnNameRegex(config.getIgnoreTableColumnNameRegex())
.build(); .build();

5
plugin/src/main/java/com/databasir/core/meta/data/DatabaseMeta.java

@ -35,6 +35,11 @@ public class DatabaseMeta {
*/ */
private String databaseName; private String databaseName;
/**
* schema_name
*/
private String schemaName;
@Builder.Default @Builder.Default
private List<TableMeta> tables = Collections.emptyList(); private List<TableMeta> tables = Collections.emptyList();

2
plugin/src/main/java/com/databasir/core/meta/repository/condition/Condition.java

@ -16,6 +16,8 @@ public class Condition {
@NonNull @NonNull
private String databaseName; private String databaseName;
private String schemaName;
@Builder.Default @Builder.Default
private Collection<String> ignoreTableNameRegex = Collections.emptyList(); private Collection<String> ignoreTableNameRegex = Collections.emptyList();

1
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java

@ -33,6 +33,7 @@ public class JdbcDatabaseMetaRepository implements DatabaseMetaRepository {
.productName(metaData.getDatabaseProductName()) .productName(metaData.getDatabaseProductName())
.productVersion(metaData.getDatabaseProductVersion()) .productVersion(metaData.getDatabaseProductVersion())
.databaseName(catalogName) .databaseName(catalogName)
.schemaName(condition.getSchemaName())
.tables(tableDocs) .tables(tableDocs)
.build(); .build();
return Optional.of(meta); return Optional.of(meta);

2
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java

@ -40,7 +40,7 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
List<TableMeta> tableMetas = new ArrayList<>(); List<TableMeta> tableMetas = new ArrayList<>();
String databaseName = condition.getDatabaseName(); String databaseName = condition.getDatabaseName();
ResultSet tablesResult = connection.getMetaData() ResultSet tablesResult = connection.getMetaData()
.getTables(databaseName, null, null, new String[]{"TABLE"}); .getTables(databaseName, condition.getSchemaName(), null, new String[]{"TABLE"});
while (tablesResult.next()) { while (tablesResult.next()) {
String tableName = tablesResult.getString("TABLE_NAME"); String tableName = tablesResult.getString("TABLE_NAME");
if (condition.tableIsIgnored(tableName)) { if (condition.tableIsIgnored(tableName)) {

Loading…
Cancel
Save