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

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

@ -1,23 +1,24 @@
package com.databasir.api.validator;
import com.databasir.core.domain.DomainErrors;
import org.springframework.stereotype.Component;
import static com.databasir.core.domain.DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN;
@Component
public class DatabaseTypeValidator {
public void isValidUrlPattern(String urlPattern) {
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}}")) {
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{jdbc.protocol}}");
throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{jdbc.protocol}}");
}
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}}")) {
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.name}}不能为空");
if (!urlPattern.contains("{{db.schema}}") && !urlPattern.contains("{{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()
.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());
}

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 {
@Mapping(target = "databaseName", source = "meta.databaseName")
@Mapping(target = "schemaName", source = "meta.schemaName")
@Mapping(target = "isArchive", constant = "false")
DatabaseDocumentPojo toDatabasePojo(Integer projectId,
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 schemaName;
private String productName;
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 schemaName;
private String productName;
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.setIgnoreTableColumnNameRegex(jsonConverter.fromJson(rule.getIgnoreColumnNameRegexArray()));
return Databasir.of(databasirConfig)
.get(jdbcConnection, dataSource.getDatabaseName())
.get(jdbcConnection, dataSource.getDatabaseName(), dataSource.getSchemaName())
.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
private String databaseName;
@NotBlank
private String schemaName;
@NotBlank
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 schemaName;
private String databaseType;
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 schemaNameContains;
private String databaseType;
private Integer groupId;
@ -29,6 +31,10 @@ public class ProjectListCondition {
Condition condition = Tables.DATA_SOURCE.DATABASE_NAME.contains(databaseNameContains);
conditions.add(condition);
}
if (schemaNameContains != null) {
Condition condition = Tables.DATA_SOURCE.SCHEMA_NAME.contains(schemaNameContains);
conditions.add(condition);
}
if (databaseType != null) {
Condition condition = Tables.DATA_SOURCE.DATABASE_TYPE.eq(databaseType);
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 schemaName;
private String databaseType;
private Boolean isAutoSync;

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

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

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

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

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

@ -169,6 +169,7 @@ public class ProjectService {
password,
request.getUrl(),
request.getDatabaseName(),
request.getSchemaName(),
request.getDatabaseType(),
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 jdbcUrl = urlPattern.replace("{{jdbc.protocol}}", type.getJdbcProtocol())
.replace("{{db.url}}", context.getUrl())
.replace("{{db.name}}", context.getSchema());
.replace("{{db.name}}", context.getDatabaseName())
.replace("{{db.schema}}", context.getSchemaName());
Properties info = new Properties();
info.put("user", context.getUsername());
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 schema;
private String databaseName;
private String schemaName;
private Properties properties;
}

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

@ -36,7 +36,8 @@ public class DatabaseConnectionService {
.username(username)
.password(password)
.url(url)
.schema(dataSource.getDatabaseName())
.databaseName(dataSource.getDatabaseName())
.schemaName(dataSource.getSchemaName())
.properties(info)
.databaseType(dataSource.getDatabaseType())
.build();
@ -54,6 +55,7 @@ public class DatabaseConnectionService {
String password,
String url,
String databaseName,
String schemaName,
String databaseType,
Properties properties) {
try {
@ -61,7 +63,8 @@ public class DatabaseConnectionService {
.username(username)
.password(password)
.url(url)
.schema(databaseName)
.databaseName(databaseName)
.schemaName(schemaName)
.properties(properties)
.databaseType(databaseType)
.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("password", context.getPassword());
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);
}

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("password", context.getPassword());
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);
}
}

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.Name;
import org.jooq.Record;
import org.jooq.Row9;
import org.jooq.Row10;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
@ -62,7 +62,12 @@ public class DataSource extends TableImpl<DataSourceRecord> {
/**
* 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>.
@ -174,11 +179,11 @@ public class DataSource extends TableImpl<DataSourceRecord> {
}
// -------------------------------------------------------------------------
// Row9 type methods
// Row10 type methods
// -------------------------------------------------------------------------
@Override
public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow();
public Row10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> 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.Keys;
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.util.Arrays;
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.
@ -64,7 +52,12 @@ public class DatabaseDocument extends TableImpl<DatabaseDocumentRecord> {
/**
* 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>.
@ -178,11 +171,11 @@ public class DatabaseDocument extends TableImpl<DatabaseDocumentRecord> {
}
// -------------------------------------------------------------------------
// Row9 type methods
// Row10 type methods
// -------------------------------------------------------------------------
@Override
public Row9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow();
public Row10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> 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 projectId;
private String databaseName;
private String schemaName;
private String databaseType;
private String url;
private String username;
@ -32,6 +33,7 @@ public class DataSourcePojo implements Serializable {
this.id = value.id;
this.projectId = value.projectId;
this.databaseName = value.databaseName;
this.schemaName = value.schemaName;
this.databaseType = value.databaseType;
this.url = value.url;
this.username = value.username;
@ -44,6 +46,7 @@ public class DataSourcePojo implements Serializable {
Integer id,
Integer projectId,
String databaseName,
String schemaName,
String databaseType,
String url,
String username,
@ -54,6 +57,7 @@ public class DataSourcePojo implements Serializable {
this.id = id;
this.projectId = projectId;
this.databaseName = databaseName;
this.schemaName = schemaName;
this.databaseType = databaseType;
this.url = url;
this.username = username;
@ -104,6 +108,20 @@ public class DataSourcePojo implements Serializable {
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>.
*/
@ -195,6 +213,7 @@ public class DataSourcePojo implements Serializable {
sb.append(id);
sb.append(", ").append(projectId);
sb.append(", ").append(databaseName);
sb.append(", ").append(schemaName);
sb.append(", ").append(databaseType);
sb.append(", ").append(url);
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 projectId;
private String databaseName;
private String schemaName;
private String productName;
private String productVersion;
private Long version;
@ -32,6 +33,7 @@ public class DatabaseDocumentPojo implements Serializable {
this.id = value.id;
this.projectId = value.projectId;
this.databaseName = value.databaseName;
this.schemaName = value.schemaName;
this.productName = value.productName;
this.productVersion = value.productVersion;
this.version = value.version;
@ -44,6 +46,7 @@ public class DatabaseDocumentPojo implements Serializable {
Integer id,
Integer projectId,
String databaseName,
String schemaName,
String productName,
String productVersion,
Long version,
@ -54,6 +57,7 @@ public class DatabaseDocumentPojo implements Serializable {
this.id = id;
this.projectId = projectId;
this.databaseName = databaseName;
this.schemaName = schemaName;
this.productName = productName;
this.productVersion = productVersion;
this.version = version;
@ -104,6 +108,20 @@ public class DatabaseDocumentPojo implements Serializable {
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>.
*/
@ -195,6 +213,7 @@ public class DatabaseDocumentPojo implements Serializable {
sb.append(id);
sb.append(", ").append(projectId);
sb.append(", ").append(databaseName);
sb.append(", ").append(schemaName);
sb.append(", ").append(productName);
sb.append(", ").append(productVersion);
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.Record1;
import org.jooq.Record9;
import org.jooq.Row9;
import org.jooq.Record10;
import org.jooq.Row10;
import org.jooq.impl.UpdatableRecordImpl;
@ -20,7 +20,7 @@ import org.jooq.impl.UpdatableRecordImpl;
* This class is generated by jOOQ.
*/
@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;
@ -66,88 +66,102 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
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>.
*/
public void setDatabaseType(String value) {
set(3, value);
set(4, value);
}
/**
* Getter for <code>databasir.data_source.database_type</code>.
*/
public String getDatabaseType() {
return (String) get(3);
return (String) get(4);
}
/**
* Setter for <code>databasir.data_source.url</code>.
*/
public void setUrl(String value) {
set(4, value);
set(5, value);
}
/**
* Getter for <code>databasir.data_source.url</code>.
*/
public String getUrl() {
return (String) get(4);
return (String) get(5);
}
/**
* Setter for <code>databasir.data_source.username</code>.
*/
public void setUsername(String value) {
set(5, value);
set(6, value);
}
/**
* Getter for <code>databasir.data_source.username</code>.
*/
public String getUsername() {
return (String) get(5);
return (String) get(6);
}
/**
* Setter for <code>databasir.data_source.password</code>.
*/
public void setPassword(String value) {
set(6, value);
set(7, value);
}
/**
* Getter for <code>databasir.data_source.password</code>.
*/
public String getPassword() {
return (String) get(6);
return (String) get(7);
}
/**
* Setter for <code>databasir.data_source.update_at</code>.
*/
public void setUpdateAt(LocalDateTime value) {
set(7, value);
set(8, value);
}
/**
* Getter for <code>databasir.data_source.update_at</code>.
*/
public LocalDateTime getUpdateAt() {
return (LocalDateTime) get(7);
return (LocalDateTime) get(8);
}
/**
* Setter for <code>databasir.data_source.create_at</code>.
*/
public void setCreateAt(LocalDateTime value) {
set(8, value);
set(9, value);
}
/**
* Getter for <code>databasir.data_source.create_at</code>.
*/
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
public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow();
public Row10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row10) super.fieldsRow();
}
@Override
public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() {
return (Row9) super.valuesRow();
public Row10<Integer, Integer, String, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() {
return (Row10) super.valuesRow();
}
@Override
@ -190,31 +204,36 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override
public Field<String> field4() {
return DataSource.DATA_SOURCE.DATABASE_TYPE;
return DataSource.DATA_SOURCE.SCHEMA_NAME;
}
@Override
public Field<String> field5() {
return DataSource.DATA_SOURCE.URL;
return DataSource.DATA_SOURCE.DATABASE_TYPE;
}
@Override
public Field<String> field6() {
return DataSource.DATA_SOURCE.USERNAME;
return DataSource.DATA_SOURCE.URL;
}
@Override
public Field<String> field7() {
return DataSource.DATA_SOURCE.USERNAME;
}
@Override
public Field<String> field8() {
return DataSource.DATA_SOURCE.PASSWORD;
}
@Override
public Field<LocalDateTime> field8() {
public Field<LocalDateTime> field9() {
return DataSource.DATA_SOURCE.UPDATE_AT;
}
@Override
public Field<LocalDateTime> field9() {
public Field<LocalDateTime> field10() {
return DataSource.DATA_SOURCE.CREATE_AT;
}
@ -235,31 +254,36 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override
public String component4() {
return getDatabaseType();
return getSchemaName();
}
@Override
public String component5() {
return getUrl();
return getDatabaseType();
}
@Override
public String component6() {
return getUsername();
return getUrl();
}
@Override
public String component7() {
return getUsername();
}
@Override
public String component8() {
return getPassword();
}
@Override
public LocalDateTime component8() {
public LocalDateTime component9() {
return getUpdateAt();
}
@Override
public LocalDateTime component9() {
public LocalDateTime component10() {
return getCreateAt();
}
@ -280,31 +304,36 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override
public String value4() {
return getDatabaseType();
return getSchemaName();
}
@Override
public String value5() {
return getUrl();
return getDatabaseType();
}
@Override
public String value6() {
return getUsername();
return getUrl();
}
@Override
public String value7() {
return getUsername();
}
@Override
public String value8() {
return getPassword();
}
@Override
public LocalDateTime value8() {
public LocalDateTime value9() {
return getUpdateAt();
}
@Override
public LocalDateTime value9() {
public LocalDateTime value10() {
return getCreateAt();
}
@ -328,42 +357,48 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
@Override
public DataSourceRecord value4(String value) {
setDatabaseType(value);
setSchemaName(value);
return this;
}
@Override
public DataSourceRecord value5(String value) {
setUrl(value);
setDatabaseType(value);
return this;
}
@Override
public DataSourceRecord value6(String value) {
setUsername(value);
setUrl(value);
return this;
}
@Override
public DataSourceRecord value7(String value) {
setUsername(value);
return this;
}
@Override
public DataSourceRecord value8(String value) {
setPassword(value);
return this;
}
@Override
public DataSourceRecord value8(LocalDateTime value) {
public DataSourceRecord value9(LocalDateTime value) {
setUpdateAt(value);
return this;
}
@Override
public DataSourceRecord value9(LocalDateTime value) {
public DataSourceRecord value10(LocalDateTime value) {
setCreateAt(value);
return this;
}
@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);
value2(value2);
value3(value3);
@ -373,6 +408,7 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
value7(value7);
value8(value8);
value9(value9);
value10(value10);
return this;
}
@ -390,12 +426,13 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
/**
* 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);
setId(id);
setProjectId(projectId);
setDatabaseName(databaseName);
setSchemaName(schemaName);
setDatabaseType(databaseType);
setUrl(url);
setUsername(username);
@ -414,6 +451,7 @@ public class DataSourceRecord extends UpdatableRecordImpl<DataSourceRecord> impl
setId(value.getId());
setProjectId(value.getProjectId());
setDatabaseName(value.getDatabaseName());
setSchemaName(value.getSchemaName());
setDatabaseType(value.getDatabaseType());
setUrl(value.getUrl());
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.Record1;
import org.jooq.Record9;
import org.jooq.Row9;
import org.jooq.Record10;
import org.jooq.Row10;
import org.jooq.impl.UpdatableRecordImpl;
@ -20,7 +20,7 @@ import org.jooq.impl.UpdatableRecordImpl;
* This class is generated by jOOQ.
*/
@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;
@ -66,88 +66,102 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
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>.
*/
public void setProductName(String value) {
set(3, value);
set(4, value);
}
/**
* Getter for <code>databasir.database_document.product_name</code>.
*/
public String getProductName() {
return (String) get(3);
return (String) get(4);
}
/**
* Setter for <code>databasir.database_document.product_version</code>.
*/
public void setProductVersion(String value) {
set(4, value);
set(5, value);
}
/**
* Getter for <code>databasir.database_document.product_version</code>.
*/
public String getProductVersion() {
return (String) get(4);
return (String) get(5);
}
/**
* Setter for <code>databasir.database_document.version</code>.
*/
public void setVersion(Long value) {
set(5, value);
set(6, value);
}
/**
* Getter for <code>databasir.database_document.version</code>.
*/
public Long getVersion() {
return (Long) get(5);
return (Long) get(6);
}
/**
* Setter for <code>databasir.database_document.is_archive</code>.
*/
public void setIsArchive(Boolean value) {
set(6, value);
set(7, value);
}
/**
* Getter for <code>databasir.database_document.is_archive</code>.
*/
public Boolean getIsArchive() {
return (Boolean) get(6);
return (Boolean) get(7);
}
/**
* Setter for <code>databasir.database_document.update_at</code>.
*/
public void setUpdateAt(LocalDateTime value) {
set(7, value);
set(8, value);
}
/**
* Getter for <code>databasir.database_document.update_at</code>.
*/
public LocalDateTime getUpdateAt() {
return (LocalDateTime) get(7);
return (LocalDateTime) get(8);
}
/**
* Setter for <code>databasir.database_document.create_at</code>.
*/
public void setCreateAt(LocalDateTime value) {
set(8, value);
set(9, value);
}
/**
* Getter for <code>databasir.database_document.create_at</code>.
*/
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
public Row9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row9) super.fieldsRow();
public Row10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row10) super.fieldsRow();
}
@Override
public Row9<Integer, Integer, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> valuesRow() {
return (Row9) super.valuesRow();
public Row10<Integer, Integer, String, String, String, String, Long, Boolean, LocalDateTime, LocalDateTime> valuesRow() {
return (Row10) super.valuesRow();
}
@Override
@ -190,31 +204,36 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override
public Field<String> field4() {
return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_NAME;
return DatabaseDocument.DATABASE_DOCUMENT.SCHEMA_NAME;
}
@Override
public Field<String> field5() {
return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_NAME;
}
@Override
public Field<String> field6() {
return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_VERSION;
}
@Override
public Field<Long> field6() {
public Field<Long> field7() {
return DatabaseDocument.DATABASE_DOCUMENT.VERSION;
}
@Override
public Field<Boolean> field7() {
public Field<Boolean> field8() {
return DatabaseDocument.DATABASE_DOCUMENT.IS_ARCHIVE;
}
@Override
public Field<LocalDateTime> field8() {
public Field<LocalDateTime> field9() {
return DatabaseDocument.DATABASE_DOCUMENT.UPDATE_AT;
}
@Override
public Field<LocalDateTime> field9() {
public Field<LocalDateTime> field10() {
return DatabaseDocument.DATABASE_DOCUMENT.CREATE_AT;
}
@ -235,31 +254,36 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override
public String component4() {
return getProductName();
return getSchemaName();
}
@Override
public String component5() {
return getProductName();
}
@Override
public String component6() {
return getProductVersion();
}
@Override
public Long component6() {
public Long component7() {
return getVersion();
}
@Override
public Boolean component7() {
public Boolean component8() {
return getIsArchive();
}
@Override
public LocalDateTime component8() {
public LocalDateTime component9() {
return getUpdateAt();
}
@Override
public LocalDateTime component9() {
public LocalDateTime component10() {
return getCreateAt();
}
@ -280,31 +304,36 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override
public String value4() {
return getProductName();
return getSchemaName();
}
@Override
public String value5() {
return getProductName();
}
@Override
public String value6() {
return getProductVersion();
}
@Override
public Long value6() {
public Long value7() {
return getVersion();
}
@Override
public Boolean value7() {
public Boolean value8() {
return getIsArchive();
}
@Override
public LocalDateTime value8() {
public LocalDateTime value9() {
return getUpdateAt();
}
@Override
public LocalDateTime value9() {
public LocalDateTime value10() {
return getCreateAt();
}
@ -328,42 +357,48 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
@Override
public DatabaseDocumentRecord value4(String value) {
setProductName(value);
setSchemaName(value);
return this;
}
@Override
public DatabaseDocumentRecord value5(String value) {
setProductName(value);
return this;
}
@Override
public DatabaseDocumentRecord value6(String value) {
setProductVersion(value);
return this;
}
@Override
public DatabaseDocumentRecord value6(Long value) {
public DatabaseDocumentRecord value7(Long value) {
setVersion(value);
return this;
}
@Override
public DatabaseDocumentRecord value7(Boolean value) {
public DatabaseDocumentRecord value8(Boolean value) {
setIsArchive(value);
return this;
}
@Override
public DatabaseDocumentRecord value8(LocalDateTime value) {
public DatabaseDocumentRecord value9(LocalDateTime value) {
setUpdateAt(value);
return this;
}
@Override
public DatabaseDocumentRecord value9(LocalDateTime value) {
public DatabaseDocumentRecord value10(LocalDateTime value) {
setCreateAt(value);
return this;
}
@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);
value2(value2);
value3(value3);
@ -373,6 +408,7 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
value7(value7);
value8(value8);
value9(value9);
value10(value10);
return this;
}
@ -390,12 +426,13 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
/**
* 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);
setId(id);
setProjectId(projectId);
setDatabaseName(databaseName);
setSchemaName(schemaName);
setProductName(productName);
setProductVersion(productVersion);
setVersion(version);
@ -414,6 +451,7 @@ public class DatabaseDocumentRecord extends UpdatableRecordImpl<DatabaseDocument
setId(value.getId());
setProjectId(value.getProjectId());
setDatabaseName(value.getDatabaseName());
setSchemaName(value.getSchemaName());
setProductName(value.getProductName());
setProductVersion(value.getProductVersion());
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,
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,
url 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
(
id INT PRIMARY KEY AUTO_INCREMENT,
project_id INT NOT NULL,
database_name TEXT NOT NULL,
product_name TEXT NOT NULL,
product_version TEXT NOT NULL,
version BIGINT NOT NULL DEFAULT 1,
is_archive BOOLEAN NOT NULL DEFAULT FALSE,
update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
project_id INT NOT NULL,
database_name VARCHAR(255) NOT NULL,
schema_name VARCHAR(255) NOT NULL,
product_name TEXT NOT NULL,
product_version TEXT NOT NULL,
version BIGINT NOT NULL DEFAULT 1,
is_archive BOOLEAN NOT NULL DEFAULT FALSE,
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)
) CHARSET utf8mb4
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;
public Optional<DatabaseMeta> get(Connection connection, String databaseName) {
public Optional<DatabaseMeta> get(Connection connection, String databaseName, String schemaName) {
Condition condition = Condition.builder()
.databaseName(databaseName)
.schemaName(schemaName)
.ignoreTableNameRegex(config.getIgnoreTableNameRegex())
.ignoreTableColumnNameRegex(config.getIgnoreTableColumnNameRegex())
.build();

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

@ -35,6 +35,11 @@ public class DatabaseMeta {
*/
private String databaseName;
/**
* schema_name
*/
private String schemaName;
@Builder.Default
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
private String databaseName;
private String schemaName;
@Builder.Default
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())
.productVersion(metaData.getDatabaseProductVersion())
.databaseName(catalogName)
.schemaName(condition.getSchemaName())
.tables(tableDocs)
.build();
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<>();
String databaseName = condition.getDatabaseName();
ResultSet tablesResult = connection.getMetaData()
.getTables(databaseName, null, null, new String[]{"TABLE"});
.getTables(databaseName, condition.getSchemaName(), null, new String[]{"TABLE"});
while (tablesResult.next()) {
String tableName = tablesResult.getString("TABLE_NAME");
if (condition.tableIsIgnored(tableName)) {

Loading…
Cancel
Save