feature: support foreign keys (#50)

* feat: support resolve foreign key

* feat: generate document foreignkey jooq model

* feat: support foreign keys

* feat:update frontend resources

* fix: checkstyle
This commit is contained in:
vran 2022-03-15 10:58:48 +08:00 committed by GitHub
parent 020671ef8a
commit 826131fed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 1586 additions and 212 deletions

View File

@ -5,6 +5,7 @@ import com.databasir.common.SystemException;
import com.databasir.core.domain.document.data.DatabaseDocumentResponse;
import com.databasir.core.domain.document.data.DatabaseDocumentSimpleResponse;
import com.databasir.core.domain.document.data.DatabaseDocumentVersionResponse;
import com.databasir.core.domain.document.data.TableDocumentResponse;
import com.databasir.core.domain.document.service.DocumentService;
import com.databasir.core.domain.log.annotation.Operation;
import lombok.RequiredArgsConstructor;
@ -89,7 +90,7 @@ public class DocumentController {
}
@PostMapping(Routes.Document.GET_TABLE_DETAIL)
public JsonData<List<DatabaseDocumentResponse.TableDocumentResponse>> getTableDocument(
public JsonData<List<TableDocumentResponse>> getTableDocument(
@PathVariable Integer projectId,
@PathVariable Integer documentId,
@RequestBody List<Integer> tableIds) {

View File

@ -1 +0,0 @@
.text{font-size:14px;line-height:1.3rem}.item{margin-top:10px;margin-right:40px}.remark-card{margin-bottom:30px}.remark-header{display:flex;justify-content:space-between;align-items:center}.remark-header .remark-user{color:#6d6d6d}.remark-header .remark-time{color:#6d6d6d;font-size:.8rem;margin-left:10px}.remark-content{white-space:pre-wrap;text-align:left}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:flex;align-items:left;justify-content:space-between;font-size:14px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:auto;scrollbar-width:thin}

View File

@ -0,0 +1 @@
@-webkit-keyframes running-line{to{stroke-dashoffset:-1000}}@keyframes running-line{to{stroke-dashoffset:-1000}}.text{font-size:14px;line-height:1.3rem}.item{margin-top:10px;margin-right:40px}.remark-card{margin-bottom:30px}.remark-header{display:flex;justify-content:space-between;align-items:center}.remark-header .remark-user{color:#6d6d6d}.remark-header .remark-time{color:#6d6d6d;font-size:.8rem;margin-left:10px}.remark-content{white-space:pre-wrap;text-align:left}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:flex;align-items:left;justify-content:space-between;font-size:14px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:auto;scrollbar-width:thin}

View File

@ -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.92d4b356.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.8031b9be.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.69b03660.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.2b5b7bc8.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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@ package com.databasir.core.domain.document.converter;
import com.databasir.core.infrastructure.converter.JsonConverter;
import com.databasir.core.meta.data.ColumnMeta;
import com.databasir.core.meta.data.ForeignKeyMeta;
import com.databasir.core.meta.data.IndexMeta;
import com.databasir.core.meta.data.TriggerMeta;
import com.databasir.dao.tables.pojos.*;
@ -66,4 +67,18 @@ public interface DocumentPojoConverter extends BaseConverter {
Integer tableDocumentId,
TriggerMeta meta);
default List<TableForeignKeyDocumentPojo> toForeignKeyPojo(Integer docId,
Integer tableMetaId,
List<ForeignKeyMeta> foreignKeys) {
return foreignKeys.stream()
.map(key -> toForeignKeyPojo(docId, tableMetaId, key))
.collect(Collectors.toList());
}
@Mapping(target = "id", ignore = true)
@Mapping(target = "createAt", ignore = true)
TableForeignKeyDocumentPojo toForeignKeyPojo(Integer databaseDocumentId,
Integer tableDocumentId,
ForeignKeyMeta foreignKey);
}

View File

@ -1,6 +1,7 @@
package com.databasir.core.domain.document.converter;
import com.databasir.core.domain.document.data.DatabaseDocumentResponse;
import com.databasir.core.domain.document.data.TableDocumentResponse;
import com.databasir.core.infrastructure.converter.JsonConverter;
import com.databasir.dao.tables.pojos.*;
import org.mapstruct.Mapper;
@ -16,28 +17,32 @@ public interface DocumentResponseConverter {
@Mapping(target = "columns", source = "columns")
@Mapping(target = "indexes", source = "indexes")
@Mapping(target = "foreignKeys", source = "foreignKeys")
@Mapping(target = "triggers", source = "triggers")
DatabaseDocumentResponse.TableDocumentResponse of(TableDocumentPojo tableDocument,
TableDocumentResponse of(TableDocumentPojo tableDocument,
List<TableColumnDocumentPojo> columns,
List<TableIndexDocumentPojo> indexes,
List<TableForeignKeyDocumentPojo> foreignKeys,
List<TableTriggerDocumentPojo> triggers);
@Mapping(target = "columns", source = "columns")
@Mapping(target = "indexes", source = "indexes")
@Mapping(target = "foreignKeys", source = "foreignKeys")
@Mapping(target = "triggers", source = "triggers")
@SuppressWarnings("checkstyle:all")
DatabaseDocumentResponse.TableDocumentResponse of(TableDocumentPojo tableDocument,
TableDocumentResponse of(TableDocumentPojo tableDocument,
Integer discussionCount,
String description,
List<DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse> columns,
List<TableDocumentResponse.ColumnDocumentResponse> columns,
List<TableIndexDocumentPojo> indexes,
List<TableForeignKeyDocumentPojo> foreignKeys,
List<TableTriggerDocumentPojo> triggers);
DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse of(TableColumnDocumentPojo pojo,
TableDocumentResponse.ColumnDocumentResponse of(TableColumnDocumentPojo pojo,
Integer discussionCount,
String description);
default List<DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse> of(
default List<TableDocumentResponse.ColumnDocumentResponse> of(
List<TableColumnDocumentPojo> columns,
String tableName,
Map<String, Integer> discussionCountMapByJoinName,
@ -52,11 +57,11 @@ public interface DocumentResponseConverter {
}
@Mapping(target = "columnNames", source = "columnNameArray")
DatabaseDocumentResponse.TableDocumentResponse.IndexDocumentResponse of(TableIndexDocumentPojo indexDocument);
TableDocumentResponse.IndexDocumentResponse of(TableIndexDocumentPojo indexDocument);
@Mapping(target = "id", source = "databaseDocument.id")
@Mapping(target = "createAt", source = "databaseDocument.createAt")
@Mapping(target = "documentVersion", source = "databaseDocument.version")
DatabaseDocumentResponse of(DatabaseDocumentPojo databaseDocument,
List<DatabaseDocumentResponse.TableDocumentResponse> tables);
List<TableDocumentResponse> tables);
}

View File

@ -32,104 +32,4 @@ public class DatabaseDocumentResponse {
private LocalDateTime createAt;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class TableDocumentResponse {
private Integer id;
private String name;
private String type;
private String comment;
private Integer discussionCount;
private String description;
@Builder.Default
private List<ColumnDocumentResponse> columns = new ArrayList<>();
@Builder.Default
private List<IndexDocumentResponse> indexes = new ArrayList<>();
@Builder.Default
private List<TriggerDocumentResponse> triggers = new ArrayList<>();
private LocalDateTime createAt;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class ColumnDocumentResponse {
private Integer id;
private String name;
private String type;
private Integer size;
private Integer decimalDigits;
private String comment;
private String description;
private Boolean isPrimaryKey;
private String nullable;
private String autoIncrement;
private String defaultValue;
private Integer discussionCount;
private LocalDateTime createAt;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class IndexDocumentResponse {
private Integer id;
private String name;
private Boolean isUnique;
@Builder.Default
private List<String> columnNames = new ArrayList<>();
private LocalDateTime createAt;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class TriggerDocumentResponse {
private Integer id;
private String name;
private String timing;
private String manipulation;
private String statement;
private String triggerCreateAt;
private LocalDateTime createAt;
}
}
}

View File

@ -0,0 +1,141 @@
package com.databasir.core.domain.document.data;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TableDocumentResponse {
private Integer id;
private String name;
private String type;
private String comment;
private Integer discussionCount;
private String description;
@Builder.Default
private List<ColumnDocumentResponse> columns = new ArrayList<>();
@Builder.Default
private List<IndexDocumentResponse> indexes = new ArrayList<>();
@Builder.Default
private List<ForeignKeyDocumentResponse> foreignKeys = new ArrayList<>();
@Builder.Default
private List<TriggerDocumentResponse> triggers = new ArrayList<>();
private LocalDateTime createAt;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class ColumnDocumentResponse {
private Integer id;
private String name;
private String type;
private Integer size;
private Integer decimalDigits;
private String comment;
private String description;
private Boolean isPrimaryKey;
private String nullable;
private String autoIncrement;
private String defaultValue;
private Integer discussionCount;
private LocalDateTime createAt;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class IndexDocumentResponse {
private Integer id;
private String name;
private Boolean isUnique;
@Builder.Default
private List<String> columnNames = new ArrayList<>();
private LocalDateTime createAt;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class ForeignKeyDocumentResponse {
private Integer id;
private String fkName;
private String fkTableName;
private String fkColumnName;
private String pkName;
private String pkTableName;
private String pkColumnName;
private String updateRule;
private String deleteRule;
private LocalDateTime createAt;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class TriggerDocumentResponse {
private Integer id;
private String name;
private String timing;
private String manipulation;
private String statement;
private String triggerCreateAt;
private LocalDateTime createAt;
}
}

View File

@ -9,6 +9,7 @@ import com.databasir.core.domain.document.converter.DocumentSimpleResponseConver
import com.databasir.core.domain.document.data.DatabaseDocumentResponse;
import com.databasir.core.domain.document.data.DatabaseDocumentSimpleResponse;
import com.databasir.core.domain.document.data.DatabaseDocumentVersionResponse;
import com.databasir.core.domain.document.data.TableDocumentResponse;
import com.databasir.core.infrastructure.connection.DatabaseConnectionService;
import com.databasir.core.infrastructure.converter.JsonConverter;
import com.databasir.core.meta.data.DatabaseMeta;
@ -57,6 +58,8 @@ public class DocumentService {
private final TableTriggerDocumentDao tableTriggerDocumentDao;
private final TableForeignKeyDocumentDao tableForeignKeyDocumentDao;
private final DocumentDiscussionDao documentDiscussionDao;
private final DocumentDescriptionDao documentDescriptionDao;
@ -109,11 +112,11 @@ public class DocumentService {
TableDocumentPojo tableMeta =
documentPojoConverter.toTablePojo(docId, table);
Integer tableMetaId = tableDocumentDao.insertAndReturnId(tableMeta);
List<TableColumnDocumentPojo> tableColumnMetas =
documentPojoConverter.toColumnPojo(docId, tableMetaId, table.getColumns());
tableColumnDocumentDao.batchInsert(tableColumnMetas);
List<TableIndexDocumentPojo> tableIndexMetas =
documentPojoConverter.toIndexPojo(docId, tableMetaId, table.getIndexes())
// column
var columns = documentPojoConverter.toColumnPojo(docId, tableMetaId, table.getColumns());
tableColumnDocumentDao.batchInsert(columns);
// index
var indexes = documentPojoConverter.toIndexPojo(docId, tableMetaId, table.getIndexes())
.stream()
.filter(index -> {
if (index.getName() != null) {
@ -124,11 +127,14 @@ public class DocumentService {
}
})
.collect(Collectors.toList());
tableIndexDocumentDao.batchInsert(indexes);
// foreign key
var foreignKeys = documentPojoConverter.toForeignKeyPojo(docId, tableMetaId, table.getForeignKeys());
tableForeignKeyDocumentDao.batchInsert(foreignKeys);
tableIndexDocumentDao.batchInsert(tableIndexMetas);
List<TableTriggerDocumentPojo> tableTriggerMetas =
documentPojoConverter.toTriggerPojo(docId, tableMetaId, table.getTriggers());
tableTriggerDocumentDao.batchInsert(tableTriggerMetas);
// trigger
var triggers = documentPojoConverter.toTriggerPojo(docId, tableMetaId, table.getTriggers());
tableTriggerDocumentDao.batchInsert(triggers);
});
log.info("save new version document success: projectId = {}, name = {}, version = {}",
projectId, meta.getDatabaseName(), version);
@ -175,24 +181,34 @@ public class DocumentService {
var columns = tableColumnDocumentDao.selectByDatabaseDocumentId(id);
var indexes = tableIndexDocumentDao.selectByDatabaseMetaId(id);
var triggers = tableTriggerDocumentDao.selectByDatabaseDocumentId(id);
var foreignKeys = tableForeignKeyDocumentDao.selectByDatabaseDocumentId(id);
Map<Integer, List<TableColumnDocumentPojo>> columnsGroupByTableMetaId = columns.stream()
.collect(Collectors.groupingBy(TableColumnDocumentPojo::getTableDocumentId));
Map<Integer, List<TableIndexDocumentPojo>> indexesGroupByTableMetaId = indexes.stream()
.collect(Collectors.groupingBy(TableIndexDocumentPojo::getTableDocumentId));
Map<Integer, List<TableTriggerDocumentPojo>> triggersGroupByTableMetaId = triggers.stream()
.collect(Collectors.groupingBy(TableTriggerDocumentPojo::getTableDocumentId));
Map<Integer, List<TableForeignKeyDocumentPojo>> foreignKeysGroupByTableMetaId = foreignKeys.stream()
.collect(Collectors.groupingBy(TableForeignKeyDocumentPojo::getTableDocumentId));
var tableDocumentResponseList = tables.stream()
.map(table -> {
Integer tableId = table.getId();
var subColumns = columnsGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
var subIndexes = indexesGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
var subTriggers = triggersGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
return documentResponseConverter.of(table, subColumns, subIndexes, subTriggers);
var subForeignKeys =
foreignKeysGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
return documentResponseConverter.of(
table,
subColumns,
subIndexes,
subForeignKeys,
subTriggers
);
})
.collect(Collectors.toList());
return documentResponseConverter.of(document, tableDocumentResponseList);
});
}
public Page<DatabaseDocumentVersionResponse> getVersionsByProjectId(Integer projectId, Pageable page) {
@ -207,7 +223,7 @@ public class DocumentService {
.orElseGet(Page::empty);
}
public List<DatabaseDocumentResponse.TableDocumentResponse> getTableDetails(Integer projectId,
public List<TableDocumentResponse> getTableDetails(Integer projectId,
Integer databaseDocumentId,
List<Integer> tableIds) {
// maybe deleted
@ -228,6 +244,12 @@ public class DocumentService {
Map<Integer, List<TableIndexDocumentPojo>> indexesGroupByTableMetaId = indexes.stream()
.collect(Collectors.groupingBy(TableIndexDocumentPojo::getTableDocumentId));
// foreign keys
var foreignKeys =
tableForeignKeyDocumentDao.selectByDatabaseDocumentIdAndTableIdIn(databaseDocumentId, tableIds);
Map<Integer, List<TableForeignKeyDocumentPojo>> foreignKeysGroupByTableMetaId = foreignKeys.stream()
.collect(Collectors.groupingBy(TableForeignKeyDocumentPojo::getTableDocumentId));
// trigger
var triggers =
tableTriggerDocumentDao.selectByDatabaseDocumentIdAndIdIn(databaseDocumentId, tableIds);
@ -259,18 +281,24 @@ public class DocumentService {
Integer tableId = table.getId();
var subColumns = columnsGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
var subIndexes = indexesGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
var subForeignKeys = foreignKeysGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
var subTriggers = triggersGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
var discussionCount = discussionCountMapByJoinName.get(table.getName());
var description = descriptionMapByJoinName.get(table.getName());
var columnResponses =
documentResponseConverter.of(
var columnResponses = documentResponseConverter.of(
subColumns,
table.getName(),
discussionCountMapByJoinName,
descriptionMapByJoinName);
return documentResponseConverter.of(table, discussionCount, description, columnResponses,
return documentResponseConverter.of(
table,
discussionCount,
description,
columnResponses,
subIndexes,
subTriggers);
subForeignKeys,
subTriggers
);
})
.collect(Collectors.toList());
}
@ -284,13 +312,13 @@ public class DocumentService {
builder.secondTitle("overview");
List<List<String>> overviewContent = new ArrayList<>();
for (int i = 0; i < doc.getTables().size(); i++) {
DatabaseDocumentResponse.TableDocumentResponse table = doc.getTables().get(i);
TableDocumentResponse table = doc.getTables().get(i);
overviewContent.add(List.of((i + 1) + "", table.getName(), table.getType(),
table.getComment()));
}
builder.table(List.of("", "表名", "类型", "备注"), overviewContent);
Function<DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse, String>
Function<TableDocumentResponse.ColumnDocumentResponse, String>
columnDefaultValueMapping = column -> {
if (Objects.equals(column.getNullable(), "YES")) {
return Objects.requireNonNullElse(column.getDefaultValue(), "null");

View File

@ -20,6 +20,7 @@ import com.databasir.dao.tables.SysKey;
import com.databasir.dao.tables.SysMail;
import com.databasir.dao.tables.TableColumnDocument;
import com.databasir.dao.tables.TableDocument;
import com.databasir.dao.tables.TableForeignKeyDocument;
import com.databasir.dao.tables.TableIndexDocument;
import com.databasir.dao.tables.TableTriggerDocument;
import com.databasir.dao.tables.User;
@ -127,6 +128,11 @@ public class Databasir extends SchemaImpl {
*/
public final TableDocument TABLE_DOCUMENT = TableDocument.TABLE_DOCUMENT;
/**
* The table <code>databasir.table_foreign_key_document</code>.
*/
public final TableForeignKeyDocument TABLE_FOREIGN_KEY_DOCUMENT = TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT;
/**
* The table <code>databasir.table_index_document</code>.
*/
@ -184,6 +190,7 @@ public class Databasir extends SchemaImpl {
SysMail.SYS_MAIL,
TableColumnDocument.TABLE_COLUMN_DOCUMENT,
TableDocument.TABLE_DOCUMENT,
TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT,
TableIndexDocument.TABLE_INDEX_DOCUMENT,
TableTriggerDocument.TABLE_TRIGGER_DOCUMENT,
User.USER,

View File

@ -9,6 +9,7 @@ import com.databasir.dao.tables.DatabaseDocument;
import com.databasir.dao.tables.DocumentDiscussion;
import com.databasir.dao.tables.TableColumnDocument;
import com.databasir.dao.tables.TableDocument;
import com.databasir.dao.tables.TableForeignKeyDocument;
import com.databasir.dao.tables.TableIndexDocument;
import com.databasir.dao.tables.TableTriggerDocument;
@ -31,11 +32,13 @@ public class Indexes {
public static final Index DATA_SOURCE_PROPERTY_IDX_DATA_SOURCE_ID = Internal.createIndex(DSL.name("idx_data_source_id"), DataSourceProperty.DATA_SOURCE_PROPERTY, new OrderField[] { DataSourceProperty.DATA_SOURCE_PROPERTY.DATA_SOURCE_ID }, false);
public static final Index TABLE_COLUMN_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableColumnDocument.TABLE_COLUMN_DOCUMENT, new OrderField[] { TableColumnDocument.TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID }, false);
public static final Index TABLE_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableDocument.TABLE_DOCUMENT, new OrderField[] { TableDocument.TABLE_DOCUMENT.DATABASE_DOCUMENT_ID }, false);
public static final Index TABLE_FOREIGN_KEY_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT, new OrderField[] { TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.DATABASE_DOCUMENT_ID }, false);
public static final Index TABLE_INDEX_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableIndexDocument.TABLE_INDEX_DOCUMENT, new OrderField[] { TableIndexDocument.TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID }, false);
public static final Index TABLE_TRIGGER_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, new OrderField[] { TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID }, false);
public static final Index DATABASE_DOCUMENT_IDX_PROJECT_ID = Internal.createIndex(DSL.name("idx_project_id"), DatabaseDocument.DATABASE_DOCUMENT, new OrderField[] { DatabaseDocument.DATABASE_DOCUMENT.PROJECT_ID }, false);
public static final Index DOCUMENT_DISCUSSION_IDX_PROJECT_ID = Internal.createIndex(DSL.name("idx_project_id"), DocumentDiscussion.DOCUMENT_DISCUSSION, new OrderField[] { DocumentDiscussion.DOCUMENT_DISCUSSION.PROJECT_ID }, false);
public static final Index TABLE_COLUMN_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableColumnDocument.TABLE_COLUMN_DOCUMENT, new OrderField[] { TableColumnDocument.TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID }, false);
public static final Index TABLE_FOREIGN_KEY_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT, new OrderField[] { TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.TABLE_DOCUMENT_ID }, false);
public static final Index TABLE_INDEX_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableIndexDocument.TABLE_INDEX_DOCUMENT, new OrderField[] { TableIndexDocument.TABLE_INDEX_DOCUMENT.TABLE_DOCUMENT_ID }, false);
public static final Index TABLE_TRIGGER_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, new OrderField[] { TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.TABLE_DOCUMENT_ID }, false);
}

View File

@ -20,6 +20,7 @@ import com.databasir.dao.tables.SysKey;
import com.databasir.dao.tables.SysMail;
import com.databasir.dao.tables.TableColumnDocument;
import com.databasir.dao.tables.TableDocument;
import com.databasir.dao.tables.TableForeignKeyDocument;
import com.databasir.dao.tables.TableIndexDocument;
import com.databasir.dao.tables.TableTriggerDocument;
import com.databasir.dao.tables.User;
@ -41,6 +42,7 @@ import com.databasir.dao.tables.records.SysKeyRecord;
import com.databasir.dao.tables.records.SysMailRecord;
import com.databasir.dao.tables.records.TableColumnDocumentRecord;
import com.databasir.dao.tables.records.TableDocumentRecord;
import com.databasir.dao.tables.records.TableForeignKeyDocumentRecord;
import com.databasir.dao.tables.records.TableIndexDocumentRecord;
import com.databasir.dao.tables.records.TableTriggerDocumentRecord;
import com.databasir.dao.tables.records.UserFavoriteProjectRecord;
@ -87,6 +89,7 @@ public class Keys {
public static final UniqueKey<SysMailRecord> KEY_SYS_MAIL_PRIMARY = Internal.createUniqueKey(SysMail.SYS_MAIL, DSL.name("KEY_sys_mail_PRIMARY"), new TableField[] { SysMail.SYS_MAIL.ID }, true);
public static final UniqueKey<TableColumnDocumentRecord> KEY_TABLE_COLUMN_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableColumnDocument.TABLE_COLUMN_DOCUMENT, DSL.name("KEY_table_column_document_PRIMARY"), new TableField[] { TableColumnDocument.TABLE_COLUMN_DOCUMENT.ID }, true);
public static final UniqueKey<TableDocumentRecord> KEY_TABLE_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableDocument.TABLE_DOCUMENT, DSL.name("KEY_table_document_PRIMARY"), new TableField[] { TableDocument.TABLE_DOCUMENT.ID }, true);
public static final UniqueKey<TableForeignKeyDocumentRecord> KEY_TABLE_FOREIGN_KEY_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT, DSL.name("KEY_table_foreign_key_document_PRIMARY"), new TableField[] { TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.ID }, true);
public static final UniqueKey<TableIndexDocumentRecord> KEY_TABLE_INDEX_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableIndexDocument.TABLE_INDEX_DOCUMENT, DSL.name("KEY_table_index_document_PRIMARY"), new TableField[] { TableIndexDocument.TABLE_INDEX_DOCUMENT.ID }, true);
public static final UniqueKey<TableTriggerDocumentRecord> KEY_TABLE_TRIGGER_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, DSL.name("KEY_table_trigger_document_PRIMARY"), new TableField[] { TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.ID }, true);
public static final UniqueKey<UserRecord> KEY_USER_PRIMARY = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_PRIMARY"), new TableField[] { User.USER.ID }, true);

View File

@ -20,6 +20,7 @@ import com.databasir.dao.tables.SysKey;
import com.databasir.dao.tables.SysMail;
import com.databasir.dao.tables.TableColumnDocument;
import com.databasir.dao.tables.TableDocument;
import com.databasir.dao.tables.TableForeignKeyDocument;
import com.databasir.dao.tables.TableIndexDocument;
import com.databasir.dao.tables.TableTriggerDocument;
import com.databasir.dao.tables.User;
@ -113,6 +114,11 @@ public class Tables {
*/
public static final TableDocument TABLE_DOCUMENT = TableDocument.TABLE_DOCUMENT;
/**
* The table <code>databasir.table_foreign_key_document</code>.
*/
public static final TableForeignKeyDocument TABLE_FOREIGN_KEY_DOCUMENT = TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT;
/**
* The table <code>databasir.table_index_document</code>.
*/

View File

@ -0,0 +1,213 @@
/*
* This file is generated by jOOQ.
*/
package com.databasir.dao.tables;
import com.databasir.dao.Databasir;
import com.databasir.dao.Indexes;
import com.databasir.dao.Keys;
import com.databasir.dao.tables.records.TableForeignKeyDocumentRecord;
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.Row12;
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.
*/
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TableForeignKeyDocument extends TableImpl<TableForeignKeyDocumentRecord> {
private static final long serialVersionUID = 1L;
/**
* The reference instance of
* <code>databasir.table_foreign_key_document</code>
*/
public static final TableForeignKeyDocument TABLE_FOREIGN_KEY_DOCUMENT = new TableForeignKeyDocument();
/**
* The class holding records for this type
*/
@Override
public Class<TableForeignKeyDocumentRecord> getRecordType() {
return TableForeignKeyDocumentRecord.class;
}
/**
* The column <code>databasir.table_foreign_key_document.id</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");
/**
* The column
* <code>databasir.table_foreign_key_document.table_document_id</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, Integer> TABLE_DOCUMENT_ID = createField(DSL.name("table_document_id"), SQLDataType.INTEGER.nullable(false), this, "");
/**
* The column
* <code>databasir.table_foreign_key_document.database_document_id</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, Integer> DATABASE_DOCUMENT_ID = createField(DSL.name("database_document_id"), SQLDataType.INTEGER.nullable(false), this, "");
/**
* The column <code>databasir.table_foreign_key_document.fk_name</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, String> FK_NAME = createField(DSL.name("fk_name"), SQLDataType.VARCHAR(255), this, "");
/**
* The column
* <code>databasir.table_foreign_key_document.fk_table_name</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, String> FK_TABLE_NAME = createField(DSL.name("fk_table_name"), SQLDataType.VARCHAR(512).nullable(false), this, "");
/**
* The column
* <code>databasir.table_foreign_key_document.fk_column_name</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, String> FK_COLUMN_NAME = createField(DSL.name("fk_column_name"), SQLDataType.VARCHAR(512).nullable(false), this, "");
/**
* The column <code>databasir.table_foreign_key_document.pk_name</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, String> PK_NAME = createField(DSL.name("pk_name"), SQLDataType.VARCHAR(255), this, "");
/**
* The column
* <code>databasir.table_foreign_key_document.pk_table_name</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, String> PK_TABLE_NAME = createField(DSL.name("pk_table_name"), SQLDataType.VARCHAR(512).nullable(false), this, "");
/**
* The column
* <code>databasir.table_foreign_key_document.pk_column_name</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, String> PK_COLUMN_NAME = createField(DSL.name("pk_column_name"), SQLDataType.VARCHAR(512).nullable(false), this, "");
/**
* The column <code>databasir.table_foreign_key_document.update_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public final TableField<TableForeignKeyDocumentRecord, String> UPDATE_RULE = createField(DSL.name("update_rule"), SQLDataType.VARCHAR(128).nullable(false), this, "NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT");
/**
* The column <code>databasir.table_foreign_key_document.delete_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public final TableField<TableForeignKeyDocumentRecord, String> DELETE_RULE = createField(DSL.name("delete_rule"), SQLDataType.VARCHAR(128).nullable(false), this, "NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT");
/**
* The column <code>databasir.table_foreign_key_document.create_at</code>.
*/
public final TableField<TableForeignKeyDocumentRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
private TableForeignKeyDocument(Name alias, Table<TableForeignKeyDocumentRecord> aliased) {
this(alias, aliased, null);
}
private TableForeignKeyDocument(Name alias, Table<TableForeignKeyDocumentRecord> aliased, Field<?>[] parameters) {
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
}
/**
* Create an aliased <code>databasir.table_foreign_key_document</code> table
* reference
*/
public TableForeignKeyDocument(String alias) {
this(DSL.name(alias), TABLE_FOREIGN_KEY_DOCUMENT);
}
/**
* Create an aliased <code>databasir.table_foreign_key_document</code> table
* reference
*/
public TableForeignKeyDocument(Name alias) {
this(alias, TABLE_FOREIGN_KEY_DOCUMENT);
}
/**
* Create a <code>databasir.table_foreign_key_document</code> table
* reference
*/
public TableForeignKeyDocument() {
this(DSL.name("table_foreign_key_document"), null);
}
public <O extends Record> TableForeignKeyDocument(Table<O> child, ForeignKey<O, TableForeignKeyDocumentRecord> key) {
super(child, key, TABLE_FOREIGN_KEY_DOCUMENT);
}
@Override
public Schema getSchema() {
return aliased() ? null : Databasir.DATABASIR;
}
@Override
public List<Index> getIndexes() {
return Arrays.asList(Indexes.TABLE_FOREIGN_KEY_DOCUMENT_IDX_DATABASE_DOCUMENT_ID, Indexes.TABLE_FOREIGN_KEY_DOCUMENT_IDX_TABLE_DOCUMENT_ID);
}
@Override
public Identity<TableForeignKeyDocumentRecord, Integer> getIdentity() {
return (Identity<TableForeignKeyDocumentRecord, Integer>) super.getIdentity();
}
@Override
public UniqueKey<TableForeignKeyDocumentRecord> getPrimaryKey() {
return Keys.KEY_TABLE_FOREIGN_KEY_DOCUMENT_PRIMARY;
}
@Override
public TableForeignKeyDocument as(String alias) {
return new TableForeignKeyDocument(DSL.name(alias), this);
}
@Override
public TableForeignKeyDocument as(Name alias) {
return new TableForeignKeyDocument(alias, this);
}
/**
* Rename this table
*/
@Override
public TableForeignKeyDocument rename(String name) {
return new TableForeignKeyDocument(DSL.name(name), null);
}
/**
* Rename this table
*/
@Override
public TableForeignKeyDocument rename(Name name) {
return new TableForeignKeyDocument(name, null);
}
// -------------------------------------------------------------------------
// Row12 type methods
// -------------------------------------------------------------------------
@Override
public Row12<Integer, Integer, Integer, String, String, String, String, String, String, String, String, LocalDateTime> fieldsRow() {
return (Row12) super.fieldsRow();
}
}

View File

@ -0,0 +1,281 @@
/*
* This file is generated by jOOQ.
*/
package com.databasir.dao.tables.pojos;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* This class is generated by jOOQ.
*/
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TableForeignKeyDocumentPojo implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private Integer tableDocumentId;
private Integer databaseDocumentId;
private String fkName;
private String fkTableName;
private String fkColumnName;
private String pkName;
private String pkTableName;
private String pkColumnName;
private String updateRule;
private String deleteRule;
private LocalDateTime createAt;
public TableForeignKeyDocumentPojo() {}
public TableForeignKeyDocumentPojo(TableForeignKeyDocumentPojo value) {
this.id = value.id;
this.tableDocumentId = value.tableDocumentId;
this.databaseDocumentId = value.databaseDocumentId;
this.fkName = value.fkName;
this.fkTableName = value.fkTableName;
this.fkColumnName = value.fkColumnName;
this.pkName = value.pkName;
this.pkTableName = value.pkTableName;
this.pkColumnName = value.pkColumnName;
this.updateRule = value.updateRule;
this.deleteRule = value.deleteRule;
this.createAt = value.createAt;
}
public TableForeignKeyDocumentPojo(
Integer id,
Integer tableDocumentId,
Integer databaseDocumentId,
String fkName,
String fkTableName,
String fkColumnName,
String pkName,
String pkTableName,
String pkColumnName,
String updateRule,
String deleteRule,
LocalDateTime createAt
) {
this.id = id;
this.tableDocumentId = tableDocumentId;
this.databaseDocumentId = databaseDocumentId;
this.fkName = fkName;
this.fkTableName = fkTableName;
this.fkColumnName = fkColumnName;
this.pkName = pkName;
this.pkTableName = pkTableName;
this.pkColumnName = pkColumnName;
this.updateRule = updateRule;
this.deleteRule = deleteRule;
this.createAt = createAt;
}
/**
* Getter for <code>databasir.table_foreign_key_document.id</code>.
*/
public Integer getId() {
return this.id;
}
/**
* Setter for <code>databasir.table_foreign_key_document.id</code>.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.table_document_id</code>.
*/
public Integer getTableDocumentId() {
return this.tableDocumentId;
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.table_document_id</code>.
*/
public void setTableDocumentId(Integer tableDocumentId) {
this.tableDocumentId = tableDocumentId;
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.database_document_id</code>.
*/
public Integer getDatabaseDocumentId() {
return this.databaseDocumentId;
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.database_document_id</code>.
*/
public void setDatabaseDocumentId(Integer databaseDocumentId) {
this.databaseDocumentId = databaseDocumentId;
}
/**
* Getter for <code>databasir.table_foreign_key_document.fk_name</code>.
*/
public String getFkName() {
return this.fkName;
}
/**
* Setter for <code>databasir.table_foreign_key_document.fk_name</code>.
*/
public void setFkName(String fkName) {
this.fkName = fkName;
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.fk_table_name</code>.
*/
public String getFkTableName() {
return this.fkTableName;
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.fk_table_name</code>.
*/
public void setFkTableName(String fkTableName) {
this.fkTableName = fkTableName;
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.fk_column_name</code>.
*/
public String getFkColumnName() {
return this.fkColumnName;
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.fk_column_name</code>.
*/
public void setFkColumnName(String fkColumnName) {
this.fkColumnName = fkColumnName;
}
/**
* Getter for <code>databasir.table_foreign_key_document.pk_name</code>.
*/
public String getPkName() {
return this.pkName;
}
/**
* Setter for <code>databasir.table_foreign_key_document.pk_name</code>.
*/
public void setPkName(String pkName) {
this.pkName = pkName;
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.pk_table_name</code>.
*/
public String getPkTableName() {
return this.pkTableName;
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.pk_table_name</code>.
*/
public void setPkTableName(String pkTableName) {
this.pkTableName = pkTableName;
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.pk_column_name</code>.
*/
public String getPkColumnName() {
return this.pkColumnName;
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.pk_column_name</code>.
*/
public void setPkColumnName(String pkColumnName) {
this.pkColumnName = pkColumnName;
}
/**
* Getter for <code>databasir.table_foreign_key_document.update_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public String getUpdateRule() {
return this.updateRule;
}
/**
* Setter for <code>databasir.table_foreign_key_document.update_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public void setUpdateRule(String updateRule) {
this.updateRule = updateRule;
}
/**
* Getter for <code>databasir.table_foreign_key_document.delete_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public String getDeleteRule() {
return this.deleteRule;
}
/**
* Setter for <code>databasir.table_foreign_key_document.delete_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public void setDeleteRule(String deleteRule) {
this.deleteRule = deleteRule;
}
/**
* Getter for <code>databasir.table_foreign_key_document.create_at</code>.
*/
public LocalDateTime getCreateAt() {
return this.createAt;
}
/**
* Setter for <code>databasir.table_foreign_key_document.create_at</code>.
*/
public void setCreateAt(LocalDateTime createAt) {
this.createAt = createAt;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TableForeignKeyDocumentPojo (");
sb.append(id);
sb.append(", ").append(tableDocumentId);
sb.append(", ").append(databaseDocumentId);
sb.append(", ").append(fkName);
sb.append(", ").append(fkTableName);
sb.append(", ").append(fkColumnName);
sb.append(", ").append(pkName);
sb.append(", ").append(pkTableName);
sb.append(", ").append(pkColumnName);
sb.append(", ").append(updateRule);
sb.append(", ").append(deleteRule);
sb.append(", ").append(createAt);
sb.append(")");
return sb.toString();
}
}

View File

@ -0,0 +1,555 @@
/*
* This file is generated by jOOQ.
*/
package com.databasir.dao.tables.records;
import com.databasir.dao.tables.TableForeignKeyDocument;
import com.databasir.dao.tables.pojos.TableForeignKeyDocumentPojo;
import java.time.LocalDateTime;
import org.jooq.Field;
import org.jooq.Record1;
import org.jooq.Record12;
import org.jooq.Row12;
import org.jooq.impl.UpdatableRecordImpl;
/**
* This class is generated by jOOQ.
*/
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TableForeignKeyDocumentRecord extends UpdatableRecordImpl<TableForeignKeyDocumentRecord> implements Record12<Integer, Integer, Integer, String, String, String, String, String, String, String, String, LocalDateTime> {
private static final long serialVersionUID = 1L;
/**
* Setter for <code>databasir.table_foreign_key_document.id</code>.
*/
public void setId(Integer value) {
set(0, value);
}
/**
* Getter for <code>databasir.table_foreign_key_document.id</code>.
*/
public Integer getId() {
return (Integer) get(0);
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.table_document_id</code>.
*/
public void setTableDocumentId(Integer value) {
set(1, value);
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.table_document_id</code>.
*/
public Integer getTableDocumentId() {
return (Integer) get(1);
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.database_document_id</code>.
*/
public void setDatabaseDocumentId(Integer value) {
set(2, value);
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.database_document_id</code>.
*/
public Integer getDatabaseDocumentId() {
return (Integer) get(2);
}
/**
* Setter for <code>databasir.table_foreign_key_document.fk_name</code>.
*/
public void setFkName(String value) {
set(3, value);
}
/**
* Getter for <code>databasir.table_foreign_key_document.fk_name</code>.
*/
public String getFkName() {
return (String) get(3);
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.fk_table_name</code>.
*/
public void setFkTableName(String value) {
set(4, value);
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.fk_table_name</code>.
*/
public String getFkTableName() {
return (String) get(4);
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.fk_column_name</code>.
*/
public void setFkColumnName(String value) {
set(5, value);
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.fk_column_name</code>.
*/
public String getFkColumnName() {
return (String) get(5);
}
/**
* Setter for <code>databasir.table_foreign_key_document.pk_name</code>.
*/
public void setPkName(String value) {
set(6, value);
}
/**
* Getter for <code>databasir.table_foreign_key_document.pk_name</code>.
*/
public String getPkName() {
return (String) get(6);
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.pk_table_name</code>.
*/
public void setPkTableName(String value) {
set(7, value);
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.pk_table_name</code>.
*/
public String getPkTableName() {
return (String) get(7);
}
/**
* Setter for
* <code>databasir.table_foreign_key_document.pk_column_name</code>.
*/
public void setPkColumnName(String value) {
set(8, value);
}
/**
* Getter for
* <code>databasir.table_foreign_key_document.pk_column_name</code>.
*/
public String getPkColumnName() {
return (String) get(8);
}
/**
* Setter for <code>databasir.table_foreign_key_document.update_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public void setUpdateRule(String value) {
set(9, value);
}
/**
* Getter for <code>databasir.table_foreign_key_document.update_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public String getUpdateRule() {
return (String) get(9);
}
/**
* Setter for <code>databasir.table_foreign_key_document.delete_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public void setDeleteRule(String value) {
set(10, value);
}
/**
* Getter for <code>databasir.table_foreign_key_document.delete_rule</code>.
* NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT
*/
public String getDeleteRule() {
return (String) get(10);
}
/**
* Setter for <code>databasir.table_foreign_key_document.create_at</code>.
*/
public void setCreateAt(LocalDateTime value) {
set(11, value);
}
/**
* Getter for <code>databasir.table_foreign_key_document.create_at</code>.
*/
public LocalDateTime getCreateAt() {
return (LocalDateTime) get(11);
}
// -------------------------------------------------------------------------
// Primary key information
// -------------------------------------------------------------------------
@Override
public Record1<Integer> key() {
return (Record1) super.key();
}
// -------------------------------------------------------------------------
// Record12 type implementation
// -------------------------------------------------------------------------
@Override
public Row12<Integer, Integer, Integer, String, String, String, String, String, String, String, String, LocalDateTime> fieldsRow() {
return (Row12) super.fieldsRow();
}
@Override
public Row12<Integer, Integer, Integer, String, String, String, String, String, String, String, String, LocalDateTime> valuesRow() {
return (Row12) super.valuesRow();
}
@Override
public Field<Integer> field1() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.ID;
}
@Override
public Field<Integer> field2() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.TABLE_DOCUMENT_ID;
}
@Override
public Field<Integer> field3() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.DATABASE_DOCUMENT_ID;
}
@Override
public Field<String> field4() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.FK_NAME;
}
@Override
public Field<String> field5() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.FK_TABLE_NAME;
}
@Override
public Field<String> field6() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.FK_COLUMN_NAME;
}
@Override
public Field<String> field7() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.PK_NAME;
}
@Override
public Field<String> field8() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.PK_TABLE_NAME;
}
@Override
public Field<String> field9() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.PK_COLUMN_NAME;
}
@Override
public Field<String> field10() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.UPDATE_RULE;
}
@Override
public Field<String> field11() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.DELETE_RULE;
}
@Override
public Field<LocalDateTime> field12() {
return TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT.CREATE_AT;
}
@Override
public Integer component1() {
return getId();
}
@Override
public Integer component2() {
return getTableDocumentId();
}
@Override
public Integer component3() {
return getDatabaseDocumentId();
}
@Override
public String component4() {
return getFkName();
}
@Override
public String component5() {
return getFkTableName();
}
@Override
public String component6() {
return getFkColumnName();
}
@Override
public String component7() {
return getPkName();
}
@Override
public String component8() {
return getPkTableName();
}
@Override
public String component9() {
return getPkColumnName();
}
@Override
public String component10() {
return getUpdateRule();
}
@Override
public String component11() {
return getDeleteRule();
}
@Override
public LocalDateTime component12() {
return getCreateAt();
}
@Override
public Integer value1() {
return getId();
}
@Override
public Integer value2() {
return getTableDocumentId();
}
@Override
public Integer value3() {
return getDatabaseDocumentId();
}
@Override
public String value4() {
return getFkName();
}
@Override
public String value5() {
return getFkTableName();
}
@Override
public String value6() {
return getFkColumnName();
}
@Override
public String value7() {
return getPkName();
}
@Override
public String value8() {
return getPkTableName();
}
@Override
public String value9() {
return getPkColumnName();
}
@Override
public String value10() {
return getUpdateRule();
}
@Override
public String value11() {
return getDeleteRule();
}
@Override
public LocalDateTime value12() {
return getCreateAt();
}
@Override
public TableForeignKeyDocumentRecord value1(Integer value) {
setId(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value2(Integer value) {
setTableDocumentId(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value3(Integer value) {
setDatabaseDocumentId(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value4(String value) {
setFkName(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value5(String value) {
setFkTableName(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value6(String value) {
setFkColumnName(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value7(String value) {
setPkName(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value8(String value) {
setPkTableName(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value9(String value) {
setPkColumnName(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value10(String value) {
setUpdateRule(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value11(String value) {
setDeleteRule(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord value12(LocalDateTime value) {
setCreateAt(value);
return this;
}
@Override
public TableForeignKeyDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, String value6, String value7, String value8, String value9, String value10, String value11, LocalDateTime value12) {
value1(value1);
value2(value2);
value3(value3);
value4(value4);
value5(value5);
value6(value6);
value7(value7);
value8(value8);
value9(value9);
value10(value10);
value11(value11);
value12(value12);
return this;
}
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
/**
* Create a detached TableForeignKeyDocumentRecord
*/
public TableForeignKeyDocumentRecord() {
super(TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT);
}
/**
* Create a detached, initialised TableForeignKeyDocumentRecord
*/
public TableForeignKeyDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String fkName, String fkTableName, String fkColumnName, String pkName, String pkTableName, String pkColumnName, String updateRule, String deleteRule, LocalDateTime createAt) {
super(TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT);
setId(id);
setTableDocumentId(tableDocumentId);
setDatabaseDocumentId(databaseDocumentId);
setFkName(fkName);
setFkTableName(fkTableName);
setFkColumnName(fkColumnName);
setPkName(pkName);
setPkTableName(pkTableName);
setPkColumnName(pkColumnName);
setUpdateRule(updateRule);
setDeleteRule(deleteRule);
setCreateAt(createAt);
}
/**
* Create a detached, initialised TableForeignKeyDocumentRecord
*/
public TableForeignKeyDocumentRecord(TableForeignKeyDocumentPojo value) {
super(TableForeignKeyDocument.TABLE_FOREIGN_KEY_DOCUMENT);
if (value != null) {
setId(value.getId());
setTableDocumentId(value.getTableDocumentId());
setDatabaseDocumentId(value.getDatabaseDocumentId());
setFkName(value.getFkName());
setFkTableName(value.getFkTableName());
setFkColumnName(value.getFkColumnName());
setPkName(value.getPkName());
setPkTableName(value.getPkTableName());
setPkColumnName(value.getPkColumnName());
setUpdateRule(value.getUpdateRule());
setDeleteRule(value.getDeleteRule());
setCreateAt(value.getCreateAt());
}
}
}

View File

@ -0,0 +1,43 @@
package com.databasir.dao.impl;
import com.databasir.dao.tables.pojos.TableForeignKeyDocumentPojo;
import lombok.Getter;
import org.jooq.DSLContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.Collections;
import java.util.List;
import static com.databasir.dao.Tables.TABLE_FOREIGN_KEY_DOCUMENT;
@Repository
public class TableForeignKeyDocumentDao extends BaseDao<TableForeignKeyDocumentPojo> {
@Autowired
@Getter
private DSLContext dslContext;
public TableForeignKeyDocumentDao() {
super(TABLE_FOREIGN_KEY_DOCUMENT, TableForeignKeyDocumentPojo.class);
}
public List<TableForeignKeyDocumentPojo> selectByDatabaseDocumentId(Integer databaseDocumentId) {
return getDslContext()
.selectFrom(TABLE_FOREIGN_KEY_DOCUMENT)
.where(TABLE_FOREIGN_KEY_DOCUMENT.DATABASE_DOCUMENT_ID.eq(databaseDocumentId))
.fetchInto(TableForeignKeyDocumentPojo.class);
}
public List<TableForeignKeyDocumentPojo> selectByDatabaseDocumentIdAndTableIdIn(Integer databaseDocumentId,
List<Integer> tableIdIn) {
if (tableIdIn == null || tableIdIn.isEmpty()) {
return Collections.emptyList();
}
return getDslContext()
.selectFrom(TABLE_FOREIGN_KEY_DOCUMENT)
.where(TABLE_FOREIGN_KEY_DOCUMENT.DATABASE_DOCUMENT_ID.eq(databaseDocumentId)
.and(TABLE_FOREIGN_KEY_DOCUMENT.TABLE_DOCUMENT_ID.in(tableIdIn)))
.fetchInto(TableForeignKeyDocumentPojo.class);
}
}

View File

@ -1,39 +0,0 @@
CREATE TABLE IF NOT EXISTS database_type
(
id INT PRIMARY KEY AUTO_INCREMENT,
database_type VARCHAR(128) NOT NULL COMMENT 'such as mysql, postgresql, mysql5.5 and so on',
icon VARCHAR(512) NOT NULL DEFAULT '',
description VARCHAR(512) NOT NULL,
jdbc_driver_file_url VARCHAR(1024) NOT NULL,
jdbc_driver_class_name VARCHAR(255) NOT NULL,
jdbc_protocol VARCHAR(128) NOT NULL,
url_pattern VARCHAR(255) NOT NULL,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
deleted_token INT NOT NULL DEFAULT 0,
update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT uk_database_type_deleted_deleted_token UNIQUE (database_type, deleted, deleted_token)
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci COMMENT 'customer database types';
REPLACE INTO databasir.database_type (id, database_type, icon, DESCRIPTION, jdbc_driver_file_url,
jdbc_driver_class_name,
jdbc_protocol, url_pattern)
VALUES (1, 'mysql', '', 'system default mysql', 'N/A', 'com.mysql.cj.jdbc.Driver', 'jdbc:mysql',
'{{jdbc.protocol}}://{{db.url}}/{{db.name}}'),
(2, 'postgresql', '', 'system default postgresql', 'N/A', 'org.postgresql.Driver', 'jdbc:postgresql',
'{{jdbc.protocol}}://{{db.url}}/{{db.name}}');
CREATE TABLE IF NOT EXISTS document_description
(
id INT PRIMARY KEY AUTO_INCREMENT,
content TEXT NOT NULL,
project_id INT NOT NULL,
table_name VARCHAR(255) NOT NULL,
column_name VARCHAR(255) DEFAULT NULL,
update_by INT NOT NULL,
update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT UNIQUE uk_project_id_table_name_column_name (project_id, table_name, column_name)
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci COMMENT 'custom document description';

View File

@ -166,6 +166,25 @@ CREATE TABLE IF NOT EXISTS table_column_document
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS table_foreign_key_document
(
id INT PRIMARY KEY AUTO_INCREMENT,
table_document_id INT NOT NULL,
database_document_id INT NOT NULL,
fk_name VARCHAR(255) DEFAULT NULL,
fk_table_name VARCHAR(512) NOT NULL,
fk_column_name VARCHAR(512) NOT NULL,
pk_name VARCHAR(255) DEFAULT NULL,
pk_table_name VARCHAR(512) NOT NULL,
pk_column_name VARCHAR(512) NOT NULL,
update_rule VARCHAR(128) NOT NULL COMMENT 'NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT',
delete_rule VARCHAR(128) NOT NULL COMMENT 'NO_ACTION, CASCADE, SET_NULL, SET_DEFAULT',
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX idx_table_document_id (table_document_id),
INDEX idx_database_document_id (database_document_id)
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS table_index_document
(
@ -270,3 +289,43 @@ CREATE TABLE IF NOT EXISTS oauth_app
UNIQUE uk_registration_id (registration_id)
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci COMMENT 'oauth app info';
CREATE TABLE IF NOT EXISTS database_type
(
id INT PRIMARY KEY AUTO_INCREMENT,
database_type VARCHAR(128) NOT NULL COMMENT 'such as mysql, postgresql, mysql5.5 and so on',
icon VARCHAR(512) NOT NULL DEFAULT '',
description VARCHAR(512) NOT NULL,
jdbc_driver_file_url VARCHAR(1024) NOT NULL,
jdbc_driver_class_name VARCHAR(255) NOT NULL,
jdbc_protocol VARCHAR(128) NOT NULL,
url_pattern VARCHAR(255) NOT NULL,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
deleted_token INT NOT NULL DEFAULT 0,
update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT uk_database_type_deleted_deleted_token UNIQUE (database_type, deleted, deleted_token)
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci COMMENT 'customer database types';
REPLACE INTO databasir.database_type (id, database_type, icon, DESCRIPTION, jdbc_driver_file_url,
jdbc_driver_class_name,
jdbc_protocol, url_pattern)
VALUES (1, 'mysql', '', 'system default mysql', 'N/A', 'com.mysql.cj.jdbc.Driver', 'jdbc:mysql',
'{{jdbc.protocol}}://{{db.url}}/{{db.name}}'),
(2, 'postgresql', '', 'system default postgresql', 'N/A', 'org.postgresql.Driver', 'jdbc:postgresql',
'{{jdbc.protocol}}://{{db.url}}/{{db.name}}');
CREATE TABLE IF NOT EXISTS document_description
(
id INT PRIMARY KEY AUTO_INCREMENT,
content TEXT NOT NULL,
project_id INT NOT NULL,
table_name VARCHAR(255) NOT NULL,
column_name VARCHAR(255) DEFAULT NULL,
update_by INT NOT NULL,
update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT UNIQUE uk_project_id_table_name_column_name (project_id, table_name, column_name)
) CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci COMMENT 'custom document description';

View File

@ -55,10 +55,18 @@ public class Databasir {
if (columnMetaRepository == null) {
columnMetaRepository = new JdbcColumnMetaRepository();
}
ForeignKeyMetaRepository foreignKeyMetaRepository = config.getForeignKeyMetaRepository();
if (foreignKeyMetaRepository == null) {
foreignKeyMetaRepository = new JdbcForeignKeyMetaRepository();
}
TableMetaRepository tableMetaRepository = config.getTableMetaRepository();
if (tableMetaRepository == null) {
tableMetaRepository =
new JdbcTableMetaRepository(columnMetaRepository, indexMetaRepository, triggerMetaRepository);
tableMetaRepository = new JdbcTableMetaRepository(
columnMetaRepository,
indexMetaRepository,
triggerMetaRepository,
foreignKeyMetaRepository
);
}
DatabaseMetaRepository databaseMetaRepository = config.getDatabaseMetaRepository();
if (databaseMetaRepository == null) {

View File

@ -17,6 +17,8 @@ public class DatabasirConfig {
private ColumnMetaRepository columnMetaRepository;
private ForeignKeyMetaRepository foreignKeyMetaRepository;
private TableMetaRepository tableMetaRepository;
private DatabaseMetaRepository databaseMetaRepository;

View File

@ -0,0 +1,37 @@
package com.databasir.core.meta.data;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class ForeignKeyMeta {
/**
* may null
*/
private String pkName;
private String pkTableName;
private String pkColumnName;
/**
* may null
*/
private String fkName;
private String fkTableName;
private String fkColumnName;
/**
* NO_ACTION \ CASCADE \ SET_NULL \ SET_DEFAULT
*/
private String updateRule;
/**
* NO_ACTION \ CASCADE \ SET_NULL \ SET_DEFAULT
*/
private String deleteRule;
}

View File

@ -25,5 +25,8 @@ public class TableMeta {
@Builder.Default
private List<IndexMeta> indexes = Collections.emptyList();
@Builder.Default
private List<ForeignKeyMeta> foreignKeys = Collections.emptyList();
private String remark;
}

View File

@ -0,0 +1,13 @@
package com.databasir.core.meta.repository;
import com.databasir.core.meta.data.ForeignKeyMeta;
import com.databasir.core.meta.repository.condition.TableCondition;
import java.sql.Connection;
import java.util.List;
public interface ForeignKeyMetaRepository {
List<ForeignKeyMeta> selectForeignKeys(Connection connection, TableCondition condition);
}

View File

@ -0,0 +1,90 @@
package com.databasir.core.meta.repository.impl.jdbc;
import com.databasir.core.meta.data.ForeignKeyMeta;
import com.databasir.core.meta.repository.ForeignKeyMetaRepository;
import com.databasir.core.meta.repository.condition.TableCondition;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class JdbcForeignKeyMetaRepository implements ForeignKeyMetaRepository {
@Override
public List<ForeignKeyMeta> selectForeignKeys(Connection connection, TableCondition condition) {
String databaseName = condition.getDatabaseName();
String schemaName = condition.getSchemaName();
String tableName = condition.getTableName();
List<ForeignKeyMeta> foreignKeys = new ArrayList<>();
ResultSet keyResult = null;
try {
keyResult = connection.getMetaData().getImportedKeys(databaseName, schemaName, tableName);
} catch (SQLException e) {
log.warn("warn: ignore foreign keys in " + databaseName + "." + tableName + ", " + e.getMessage());
return foreignKeys;
}
try {
keyResult = connection.getMetaData()
.getImportedKeys(databaseName, schemaName, tableName);
while (keyResult.next()) {
String fkTableName = keyResult.getString("FKTABLE_NAME");
String fkColumnName = keyResult.getString("FKCOLUMN_NAME");
String fkName = keyResult.getString("FK_NAME");
String pkTableName = keyResult.getString("PKTABLE_NAME");
String pkColumnName = keyResult.getString("PKCOLUMN_NAME");
String pkName = keyResult.getString("PK_NAME");
int updateRule = keyResult.getInt("UPDATE_RULE");
int deleteRule = keyResult.getInt("DELETE_RULE");
ForeignKeyMeta meta = ForeignKeyMeta.builder()
.fkTableName(fkTableName)
.fkColumnName(fkColumnName)
.fkName(fkName)
.pkTableName(pkTableName)
.pkColumnName(pkColumnName)
.pkName(pkName)
.updateRule(updateRuleConvert(updateRule))
.deleteRule(deleteRuleConvert(deleteRule))
.build();
foreignKeys.add(meta);
}
} catch (SQLException e) {
log.warn("warn: ignore foreign keys in " + databaseName + "." + tableName + ", " + e.getMessage());
}
return foreignKeys;
}
private String updateRuleConvert(int updateRule) {
return doMapping(updateRule, "update");
}
private String deleteRuleConvert(int deleteRule) {
return doMapping(deleteRule, "delete");
}
private String doMapping(int rule, String type) {
if (rule == DatabaseMetaData.importedKeyCascade) {
return "CASCADE";
}
if (rule == DatabaseMetaData.importedKeyRestrict) {
return "CASCADE";
}
if (rule == DatabaseMetaData.importedKeyNoAction) {
return "RESTRICT";
}
if (rule == DatabaseMetaData.importedKeySetNull) {
return "SET_NULL";
}
if (rule == DatabaseMetaData.importedKeySetDefault) {
return "SET_DEFAULT";
}
log.warn("can not map foreign key " + type + " rule = " + rule);
return "";
}
}

View File

@ -2,10 +2,7 @@ package com.databasir.core.meta.repository.impl.jdbc;
import com.databasir.core.meta.data.ColumnMeta;
import com.databasir.core.meta.data.TableMeta;
import com.databasir.core.meta.repository.ColumnMetaRepository;
import com.databasir.core.meta.repository.IndexMetaRepository;
import com.databasir.core.meta.repository.TableMetaRepository;
import com.databasir.core.meta.repository.TriggerMetaRepository;
import com.databasir.core.meta.repository.*;
import com.databasir.core.meta.repository.condition.Condition;
import com.databasir.core.meta.repository.condition.TableCondition;
import lombok.RequiredArgsConstructor;
@ -27,6 +24,8 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
private final TriggerMetaRepository triggerMetaRepository;
private final ForeignKeyMetaRepository foreignKeyMetaRepository;
@Override
public List<TableMeta> selectTables(Connection connection, Condition condition) {
try {
@ -63,6 +62,7 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
.type(tableType)
.comment(tableComment)
.columns(columns)
.foreignKeys(foreignKeyMetaRepository.selectForeignKeys(connection, tableCondition))
.indexes(indexMetaRepository.selectIndexes(connection, tableCondition))
.triggers(triggerMetaRepository.selectTriggers(connection, tableCondition))
.build();