Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions forward_engineering/ddlProvider/ddlHelpers/indexHelper.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
/**
* @import { IndexDto } from '../../types'
*/

const _ = require('lodash');
const { escapeSingleQuote, normalizeLineEndings } = require('../../utils/general');
const { normalizeLineEndings } = require('../../utils/general');

module.exports = ({ prepareName, getNamePrefixedWithSchemaName }) => {
const getIndexType = indexType => {
return indexType ? ` ${_.toUpper(indexType)}` : '';
};

/**
*
* @param param0
* @param {IndexDto} param0.index
* @returns {string}
*/
const getIndexName = ({ index }) => {
return index.indxName ? ` ${getNamePrefixedWithSchemaName(index.indxName, index.schemaName)}` : '';
if (!index.indxName) {
return '';
}

// `index.indxSchema` - is custom schema name from cross schema indexes, specified manually by user
// `index.schemaName` - is schema name where the actually table created
const schemaName = index.indxSchema || index.schemaName;
return ` ${getNamePrefixedWithSchemaName(index.indxName, schemaName)}`;
};

/**
Expand Down
12 changes: 12 additions & 0 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @import { IndexDto } from '../types'
*/

const _ = require('lodash');
const defaultTypes = require('../configs/defaultTypes');
const descriptors = require('../configs/descriptors');
Expand Down Expand Up @@ -502,6 +506,14 @@ module.exports = (baseProvider, options, app) => {
return { ...indexData, schemaName: schemaData.schemaName, indexAnnotations: indexData.indexAnnotations };
},

/**
*
* @param {string} tableName
* @param {IndexDto} index
* @param {Record<string, unknown>} [dbData]
* @param {boolean} [isParentActivated]
* @returns {string}
*/
createIndex(tableName, index, dbData, isParentActivated = true) {
const name = getIndexName({ index });
const hasKeys = !!index.indxKey.length || !!_.trim(index.column_expression);
Expand Down
64 changes: 48 additions & 16 deletions forward_engineering/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,60 @@
export type ColumnDefinition = {
name: string;
type: string;
isActivated: boolean;
length?: number;
precision?: number;
primaryKey?: boolean;
scale?: number;
timePrecision?: number;
unique?: boolean;
primaryKeyOptions?: Array<{ GUID: string; constraintName: string }>
uniqueKeyOptions?: Array<{ GUID: string; constraintName: string }>
name: string;
type: string;
isActivated: boolean;
length?: number;
precision?: number;
primaryKey?: boolean;
scale?: number;
timePrecision?: number;
unique?: boolean;
primaryKeyOptions?: Array<{ GUID: string; constraintName: string }>;
uniqueKeyOptions?: Array<{ GUID: string; constraintName: string }>;
};

export type ConstraintDtoColumn = {
name: string;
isActivated: boolean;
name: string;
isActivated: boolean;
};

export type KeyType = 'PRIMARY KEY' | 'UNIQUE';

export type ConstraintDto = {
keyType: KeyType;
name: string;
columns: ConstraintDtoColumn[];
keyType: KeyType;
name: string;
columns: ConstraintDtoColumn[];
};

export type JsonSchema = Record<string, unknown>;

export type Annotation = {
annotationName?: string;
annotationValue?: string;
};

export type IndexKeyDto = {
name?: string | null;
type?: string;
keyId?: string;
};

export type IndexDto = {
id?: string;
indxName?: string;
isActivated?: boolean;
ifNotExist?: boolean;
indxSchema?: string; // cross schema name specified manually by user
indxType?: string;
schemaName?: string;
indxKey: IndexKeyDto[];
column_expression?: string;
indxDescription?: string;
comments?: string;
tablespace?: string;
index_properties?: string;
index_attributes?: string;
index_compression?: string;
logging_clause?: string;
indexAnnotations?: Annotation[];
indxComments?: string;
};
6 changes: 6 additions & 0 deletions properties_pane/entity_level/entityLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,12 @@ making sure that you maintain a proper JSON format.
"propertyKeyword": "ifNotExist",
"propertyType": "checkbox"
},
{
"propertyName": "Index schema",
"propertyKeyword": "indxSchema",
"propertyTooltip": "",
"propertyType": "text"
},
{
"propertyName": "Type",
"propertyKeyword": "indxType",
Expand Down
Loading