diff --git a/forward_engineering/config.json b/forward_engineering/config.json index 079434a..0eeae5b 100644 --- a/forward_engineering/config.json +++ b/forward_engineering/config.json @@ -32,5 +32,436 @@ "name": "Apply Drop Statements", "isDropInStatements": true } + ], + "scriptGenerationOptions": [ + { + "keyword": "primaryKeys", + "label": "FE_SCRIPT_GENERATION_OPTIONS___PRIMARY_KEYS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "primaryKey", + "valueType": "array" + }, + "defaultValue": { + "primaryKey": [] + } + }, + { + "dependency": { + "key": "primaryKey", + "valueType": "object" + }, + "defaultValue": { + "primaryKey": {} + } + }, + { + "dependency": { + "type": "or", + "values": [ + { + "key": "primaryKey", + "value": true + }, + { + "key": "compositePrimaryKey", + "value": true + } + ] + }, + "defaultValue": { + "primaryKey": false, + "compositePrimaryKey": false + } + } + ] + }, + { + "keyword": "foreignKeys", + "label": "FE_SCRIPT_GENERATION_OPTIONS___FOREIGN_KEYS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + } + }, + { + "keyword": "uniqueConstraints", + "label": "FE_SCRIPT_GENERATION_OPTIONS___UNIQUE_KEYS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "uniqueKey", + "valueType": "array" + }, + "defaultValue": { + "uniqueKey": [] + } + }, + { + "dependency": { + "key": "uniqueKey", + "valueType": "object" + }, + "defaultValue": { + "uniqueKey": {} + } + }, + { + "dependency": { + "type": "or", + "values": [ + { + "key": "unique", + "value": true + }, + { + "key": "compositeUniqueKey", + "value": true + }, + { + "key": "compMode", + "exist": true + } + ] + }, + "defaultValue": { + "unique": false, + "compositeUniqueKey": false + } + } + ] + }, + { + "keyword": "columnNotNullConstraints", + "label": "FE_SCRIPT_GENERATION_OPTIONS___COLUMN_NOT_NULL", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "required", + "value": true + }, + "defaultValue": { + "required": false + } + } + ] + }, + { + "keyword": "checkConstraints", + "label": "FE_SCRIPT_GENERATION_OPTIONS___CHECK_CONSTRAINTS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "type": "or", + "values": [ + { + "key": "chkConstr", + "valueType": "array" + }, + { + "key": "checkConstraint", + "valueType": "array" + } + ] + }, + "defaultValue": { + "chkConstr": [], + "checkConstraint": [] + } + } + ] + }, + { + "keyword": "columnDefaultValues", + "label": "FE_SCRIPT_GENERATION_OPTIONS___COLUMN_DEFAULT_VALUES", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "default", + "exist": true + }, + "defaultValue": { + "default": "" + } + } + ] + }, + { + "keyword": "schemaComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___SCHEMA_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "type": "and", + "values": [ + { + "key": "type", + "value": "bucket" + }, + { + "key": "description", + "exist": true + } + ] + }, + "defaultValue": { + "description": "" + } + } + ] + }, + { + "keyword": "tableComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___TABLE_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "type": "and", + "values": [ + { + "key": "collectionName", + "exist": true + }, + { + "key": "description", + "exist": true + } + ] + }, + "defaultValue": { + "description": "" + } + } + ] + }, + { + "keyword": "viewComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___VIEW_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "viewOn", + "exist": true + }, + "defaultValue": { + "description": "" + } + } + ] + }, + { + "keyword": "columnComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___COLUMN_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "type": "and", + "values": [ + { + "type": "not", + "values": [ + { + "key": "type", + "value": "bucket" + } + ] + }, + { + "key": "collectionName", + "exist": false + }, + { + "key": "viewOn", + "exist": false + }, + { + "key": "description", + "exist": true + } + ] + }, + "defaultValue": { + "description": "" + } + } + ] + } ] } diff --git a/forward_engineering/configs/templates.js b/forward_engineering/configs/templates.js index e59eefe..c87ca81 100644 --- a/forward_engineering/configs/templates.js +++ b/forward_engineering/configs/templates.js @@ -1,60 +1,79 @@ module.exports = { createDatabase: 'CREATE DATABASE "${name}" AS ${databaseOptions};', createSession: 'SET SESSION DATABASE "${name}";', + dropDatabase: 'DROP DATABASE "${databaseName}";', + modifyDatabase: 'MODIFY DATABASE "${databaseName}" AS ${databaseOptions};', + commentDatabase: 'COMMENT ON DATABASE ${databaseName}\nIS ${comment};', + columnDefinition: - '"${name}" ${type}${inlineLength}${not_null}${uppercase}${caseSpecific}${format}${default}${storageFormat}${characterSet}${withSchema}${autoColumn}${compress}${compressUsing}${decompressUsing}${inlineCheckConstraint}${inlineUniqueConstraint}${inlinePKConstraint}', + '${name}${type}${inlineLength}${not_null}${uppercase}${caseSpecific}${format}${default}${storageFormat}${characterSet}${withSchema}${autoColumn}${compress}${compressUsing}${decompressUsing}${inlineCheckConstraint}${inlineUniqueConstraint}${inlinePKConstraint}', createTable: 'CREATE${tableSet}${temporary}${traceTable} TABLE ${name}${tableOptions} (\n' + '\t\t${column_definitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' + - '\t)${tableIndexes}${tablePreservation};\n', + '\t)${tableIndexes}${tablePreservation};', createAsSelectTable: 'CREATE${tableSet}${temporary} TABLE ${name}${tableOptions} (\n' + '\t\t${column_definitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' + '\t)' + '\n\tAS (\n' + '\t${selectStatement} ' + - '\n\t)${tableIndexes}${tablePreservation};\n', - createErrorTable: 'CREATE ERROR TABLE ${tableName} FOR ${targetDataTable};\n', + '\n\t)${tableIndexes}${tablePreservation};', + createErrorTable: 'CREATE ERROR TABLE ${tableName} FOR ${targetDataTable};', createForeignTable: 'CREATE FOREIGN TABLE ${name}${tableOptions} (\n' + '\t\t${column_definitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' + '\t)\n' + '\tUSING (\n' + '\t${usingOptions}\n' + - '\t)${tableIndexes}${tablePreservation};\n', + '\t)${tableIndexes}${tablePreservation};', createHashIndex: 'CREATE HASH INDEX ${indexName}${indexOptions} (\n' + '\t\t${indexKeys}' + '\n\t)' + - '\n\tON ${tableName}${orderBy};\n', - createJoinIndex: 'CREATE JOIN INDEX ${indexName}${indexOptions}' + '\n\tAS ${selectStatement};\n', - createKeyConstraint: 'CONSTRAINT ${constraintName}${constraintType}${columns}', + '\n\tON ${tableName}${orderBy};', + createJoinIndex: 'CREATE JOIN INDEX ${indexName}${indexOptions}' + '\n\tAS ${selectStatement};', + createKeyConstraint: '${constraintName}${constraintType} (${columns})', checkConstraint: '${name}${expression}', - createForeignKeyConstraint: 'FOREIGN KEY (${foreignKey}) REFERENCES ${checkOption} ${primaryTable} (${primaryKey})', - createView: 'CREATE${recursive} VIEW ${name} (\n' + '\t${columnList}\n' + ')\nAS ${selectStatement};\n', + + createForeignKeyConstraint: + '${constraintName}FOREIGN KEY (${foreignKey}) REFERENCES ${checkOption} ${primaryTable} (${primaryKey})', + dropForeignKeyUnnamed: + 'ALTER TABLE ${tableName} DROP FOREIGN KEY (${foreignKey}) REFERENCES ${primaryTable} (${primaryKey});', + + createView: 'CREATE${recursive} VIEW ${name} (\n' + '\t${columnList}\n' + ')\nAS ${selectStatement};', viewSelectStatement: 'SELECT ${keys}\n\tFROM ${tableName}', createStructuredType: - 'CREATE TYPE ${typeName} AS (\n' + '\t${columnDefinitions}' + '\n)\n' + 'NOT FINAL${methodSpecification};\n', - createDistinctType: 'CREATE TYPE ${typeName} AS ${baseType} FINAL${methodSpecification};\n', - createArrayType: 'CREATE TYPE ${typeName} AS ${baseType}${default};\n', - - dropDatabase: 'DROP DATABASE "${databaseName}";\n', - modifyDatabase: 'MODIFY DATABASE "${databaseName}" AS ${databaseOptions};\n', + 'CREATE TYPE ${typeName} AS (\n' + '\t${columnDefinitions}' + '\n)\n' + 'NOT FINAL${methodSpecification};', + createDistinctType: 'CREATE TYPE ${typeName} AS ${baseType} FINAL${methodSpecification};', + createArrayType: 'CREATE TYPE ${typeName} AS ${baseType}${default};', - dropTable: 'DROP ${temporary}TABLE ${name};\n', + dropTable: 'DROP ${temporary}TABLE ${name};', alterTable: 'ALTER TABLE ${tableName}${tableOptions}${alterStatement};', + renameTable: 'RENAME TABLE ${oldName} TO ${newName};', + commentTable: 'COMMENT ON TABLE ${tableName}\nIS ${comment};', addColumn: ' ADD ${columnDefinition}', + alterColumn: 'ALTER TABLE ${tableName} ADD ${columnName} ${columnDefinition};', dropColumn: ' DROP ${name}', rename: ' RENAME ${oldName} TO ${newName}', + commentColumn: 'COMMENT ON COLUMN ${columnName}\nIS ${comment};', dropCheckConstraint: ' DROP CONSTRAINT ${name} CHECK', - addCheckConstraint: ' ADD CONSTRAINT ${name} ${expression}', - modifyCheckConstraint: ' MODIFY CONSTRAINT ${name} ${expression}', + addCheckConstraint: ' ADD ${constraintName}${expression}', + alterCheckConstraint: ' ADD ${constraintName}${expression}', + createSecondaryIndex: 'CREATE ${indexStatement} ON ${tableName};', dropSecondaryIndex: 'DROP INDEX ${indexName} ON ${tableName};', dropIndex: 'DROP${indexType} INDEX ${indexName};', dropView: 'DROP VIEW ${viewName};', renameView: 'RENAME VIEW ${oldViewName} TO ${newViewName};', + commentView: 'COMMENT ON VIEW ${viewName}\nIS ${comment};', + + dropConstraint: 'ALTER TABLE ${tableName} DROP CONSTRAINT ${constraintName};', + + alterPrimaryKey: 'ALTER TABLE ${tableName} ADD ${constraintName}PRIMARY KEY (${columns});', + alterUniqueKey: 'ALTER TABLE ${tableName} ADD ${constraintName}UNIQUE (${columns});', + + dropUnnamedIndex: 'DROP INDEX (${columns}) ON ${tableName};', }; diff --git a/forward_engineering/ddlProvider.js b/forward_engineering/ddlProvider.js index 486fc34..0170a32 100644 --- a/forward_engineering/ddlProvider.js +++ b/forward_engineering/ddlProvider.js @@ -34,23 +34,30 @@ module.exports = (baseProvider, options, app) => { }); const keyHelper = require('./helpers/keyHelper')(clean); const { - getTableName, - getIndexName, + prepareName, getDatabaseOptions, getViewData, getJournalingStrategy, viewColumnsToString, shouldDropDefaultJournalTable, + prepareComment, + getOldName, } = require('./helpers/general')(_, tab, commentIfDeactivated); - const { getTableOptions, getUsingOptions, getInlineTableIndexes, getIndexOptions, getIndexKeys } = - require('./helpers/tableHelper')({ - _, - tab, - getJournalingStrategy, - commentIfDeactivated, - checkAllKeysDeactivated, - divideIntoActivatedAndDeactivated, - }); + const { + getTableOptions, + getUsingOptions, + getInlineTableIndexes, + getIndexOptions, + getIndexKeys, + getTableInlineIndexStatement, + } = require('./helpers/tableHelper')({ + _, + tab, + getJournalingStrategy, + commentIfDeactivated, + checkAllKeysDeactivated, + divideIntoActivatedAndDeactivated, + }); const { decorateType } = require('./helpers/columnDefinitionHelper'); const additionalOptions = getAdditionalOptions(options.additionalOptions); @@ -64,6 +71,7 @@ module.exports = (baseProvider, options, app) => { db_default_map: containerData.db_default_map, db_permanent_storage_size: containerData.db_permanent_storage_size, spool_files_size: containerData.spool_files_size, + temporary_tables_size: containerData.temporary_tables_size, has_fallback: containerData.has_fallback, db_before_journaling_strategy: containerData.db_before_journaling_strategy, db_after_journaling_strategy: containerData.db_after_journaling_strategy, @@ -164,6 +172,7 @@ module.exports = (baseProvider, options, app) => { compressUsing: jsonSchema.compressUsing, decompressUsing: jsonSchema.decompressUsing, methodSpecification: jsonSchema.methodSpecification, + description: jsonSchema.description, }; }, @@ -174,6 +183,7 @@ module.exports = (baseProvider, options, app) => { db_default_map, db_permanent_storage_size, spool_files_size, + temporary_tables_size, has_fallback, db_before_journaling_strategy, db_after_journaling_strategy, @@ -185,6 +195,7 @@ module.exports = (baseProvider, options, app) => { db_default_map, db_permanent_storage_size, spool_files_size, + temporary_tables_size, has_fallback, db_before_journaling_strategy, db_after_journaling_strategy, @@ -264,7 +275,7 @@ module.exports = (baseProvider, options, app) => { const { name, dbData, columns, checkConstraints, foreignKeyConstraints, selectStatement, tableOptions } = tableData; const preparedTableOptions = getTableOptions(tableOptions); - const tableName = getTableName(name, dbData.databaseName); + const tableName = prepareName(name, dbData.databaseName); const tableIndexes = getInlineTableIndexes(tableData); const tablePreservationStatement = tableOptions.TABLE_PRESERVATION ? `\n\tON COMMIT ${tableOptions.TABLE_PRESERVATION}` @@ -362,7 +373,7 @@ module.exports = (baseProvider, options, app) => { return commentIfDeactivated( assignTemplates(templates.createView, { - name: getTableName(viewData.name, dbData.databaseName), + name: prepareName(viewData.name, dbData.databaseName), recursive: viewData.recursive ? ' RECURSIVE' : '', selectStatement, columnList: viewColumnsToString(viewData.keys, isActivated), @@ -399,8 +410,11 @@ module.exports = (baseProvider, options, app) => { }, createIndex(tableName, index, dbData, isParentActivated = true) { - const inlineIndex = !['HASH', 'JOIN'].includes(index.indexType); - if (inlineIndex || !index.indxName) { + const canCreate = + (['HASH', 'JOIN'].includes(index.indexType) && Boolean(index.indxName)) || + ['SECONDARY', ''].includes(index.indexType); + + if (!canCreate) { return ''; } @@ -422,8 +436,8 @@ module.exports = (baseProvider, options, app) => { return commentIfDeactivated( assignTemplates(templates.createHashIndex, { - indexName: getIndexName(index.indxName, dbData.databaseName), - tableName: getTableName(tableName, dbData.databaseName), + indexName: prepareName(index.indxName, dbData.databaseName), + tableName: prepareName(tableName, dbData.databaseName), indexKeys: getIndexKeys(index.indxKey), orderBy, indexOptions, @@ -439,7 +453,7 @@ module.exports = (baseProvider, options, app) => { return commentIfDeactivated( assignTemplates(templates.createJoinIndex, { - indexName: getIndexName(index.indxName, dbData.databaseName), + indexName: prepareName(index.indxName, dbData.databaseName), selectStatement: index.asSelect, indexOptions, }), @@ -447,6 +461,20 @@ module.exports = (baseProvider, options, app) => { isActivated: isParentActivated && index.isActivated, }, ); + } else if (!index.indexType || index.indexType === 'SECONDARY') { + if (_.isEmpty(index.indxKey)) { + return ''; + } + const indexStatement = getTableInlineIndexStatement(index); + return commentIfDeactivated( + assignTemplates(templates.createSecondaryIndex, { + indexStatement, + tableName: prepareName(tableName, dbData.databaseName), + }), + { + isActivated: isParentActivated && index.isActivated, + }, + ); } return ''; @@ -466,13 +494,13 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ createCheckConstraintStatement(tableName, checkConstraint, dbData) { - const table = getTableName(tableName, dbData.databaseName); + const table = prepareName(tableName, dbData.databaseName); return assignTemplates(templates.alterTable, { tableName: table, tableOptions: '', alterStatement: assignTemplates(templates.addCheckConstraint, { - name: wrap(checkConstraint.name, '"', '"'), + constraintName: checkConstraint.name ? `CONSTRAINT ${prepareName(checkConstraint.name)} ` : '', expression: checkConstraint.expression, }), }); @@ -485,7 +513,7 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ dropCheckConstraint(tableName, checkConstraint, dbData) { - const table = getTableName(tableName, dbData.databaseName); + const table = prepareName(tableName, dbData.databaseName); return assignTemplates(templates.alterTable, { tableName: table, @@ -504,46 +532,28 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ alterCheckConstraint(tableName, { new: newCheck, old: oldCheck }, dbData) { - const table = getTableName(tableName, dbData.databaseName); - - const alterStatements = []; - if (newCheck.chkConstrName !== oldCheck.chkConstrName) { - const renameConstraint = assignTemplates(templates.rename, { - oldName: wrap(oldCheck.chkConstrName, '"', '"'), - newName: wrap(newCheck.chkConstrName, '"', '"'), - }); - - alterStatements.push(renameConstraint); - } - - if (newCheck.constrExpression !== oldCheck.constrExpression) { - const modifyConstraint = assignTemplates(templates.modifyCheckConstraint, { - name: wrap(oldCheck.chkConstrName, '"', '"'), - expression: newCheck.chkConstrName, - }); - - alterStatements.push(modifyConstraint); + if (newCheck.name !== oldCheck.name || newCheck.expression !== oldCheck.expression) { + return [ + this.dropCheckConstraint(tableName, oldCheck, dbData), + this.createCheckConstraintStatement(tableName, oldCheck, dbData), + ].join('\n\n'); } - return assignTemplates(templates.alterTable, { - tableName: table, - tableOptions: '', - alterStatement: '\n' + tab(alterStatements.join(',\n')), - }); + return ''; }, - createForeignKeyConstraint( - { + createForeignKeyConstraint(relationship) { + const { foreignKey, primaryTable, + primarySchemaName, primaryKey, primaryTableActivated, foreignTableActivated, customProperties, isActivated, - }, - dbData, - ) { + name, + } = relationship; const isAllPrimaryKeysDeactivated = checkAllKeysDeactivated(primaryKey); const isAllForeignKeysDeactivated = checkAllKeysDeactivated(foreignKey); const isRelationshipActivated = @@ -555,8 +565,9 @@ module.exports = (baseProvider, options, app) => { return { statement: assignTemplates(templates.createForeignKeyConstraint, { + constraintName: name ? `CONSTRAINT ${prepareName(name)} ` : '', checkOption: customProperties.checkOption, - primaryTable: getTableName(primaryTable, dbData.databaseName), + primaryTable: prepareName(primaryTable, primarySchemaName), foreignKey: isRelationshipActivated ? foreignKeysToString(foreignKey) : foreignActiveKeysToString(foreignKey), @@ -568,10 +579,65 @@ module.exports = (baseProvider, options, app) => { }; }, + createForeignKey(relationship) { + const { foreignTable, foreignSchemaName } = relationship; + const tableName = prepareName(foreignTable, foreignSchemaName); + + const { statement: foreignKeyStatement } = this.createForeignKeyConstraint(relationship); + + return assignTemplates(templates.alterTable, { + tableName, + alterStatement: ' ADD ' + foreignKeyStatement, + }); + }, + + dropForeignKey(relationship) { + const { + foreignKey, + primaryTable, + primarySchemaName, + primaryKey, + primaryTableActivated, + foreignTableActivated, + isActivated, + name, + foreignTable, + foreignSchemaName, + } = relationship; + const tableName = prepareName(foreignTable, foreignSchemaName); + const isAllPrimaryKeysDeactivated = checkAllKeysDeactivated(primaryKey); + const isAllForeignKeysDeactivated = checkAllKeysDeactivated(foreignKey); + const isRelationshipActivated = + !isAllPrimaryKeysDeactivated && + !isAllForeignKeysDeactivated && + primaryTableActivated && + foreignTableActivated && + isActivated !== false; + + return name + ? assignTemplates(templates.dropConstraint, { + tableName, + constraintName: prepareName(name), + }) + : assignTemplates(templates.dropForeignKeyUnnamed, { + tableName, + primaryTable: prepareName(primaryTable, primarySchemaName), + foreignKey: isRelationshipActivated + ? foreignKeysToString(foreignKey) + : foreignActiveKeysToString(foreignKey), + primaryKey: isRelationshipActivated + ? foreignKeysToString(primaryKey) + : foreignActiveKeysToString(primaryKey), + }); + }, + convertColumnDefinition(columnDefinition) { - const type = this.hasType(columnDefinition.type) - ? decorateType(columnDefinition.type, columnDefinition) - : `"${columnDefinition.type}"`; + let type = ''; + if (columnDefinition.type) { + type = this.hasType(columnDefinition.type) + ? ` ${decorateType(columnDefinition.type, columnDefinition)}` + : ` "${columnDefinition.type}"`; + } const inlineLength = columnDefinition.inlineLength ? ` INLINE LENGTH ${columnDefinition.inlineLength}` : ''; const notNull = columnDefinition.required ? ' NOT NULL' : ''; const inlineUniqueConstraint = columnDefinition.unique && !columnDefinition.nullable ? ' UNIQUE' : ''; @@ -596,7 +662,7 @@ module.exports = (baseProvider, options, app) => { return commentIfDeactivated( assignTemplates(templates.columnDefinition, { - name: columnDefinition.name, + name: prepareName(columnDefinition.name), not_null: notNull, default: defaultValue, type, @@ -658,6 +724,8 @@ module.exports = (baseProvider, options, app) => { return { name: data.name || '', + oldDescription: compModeData.old.description?.trim() || null, + newDescription: compModeData.new.description?.trim() || null, ...(isDbAccountModified && { db_account: data.db_account }), ...(isDefaultMapModified && { db_default_map: data.db_default_map }), ...(isPermanentStorageSizeModified && { db_permanent_storage_size: data.db_permanent_storage_size }), @@ -703,7 +771,7 @@ module.exports = (baseProvider, options, app) => { * @param {EntityData} oldEntityData * @return {ModifyEntityData} */ - hydrateAlterTable({ name, newEntityData, oldEntityData }) { + hydrateAlterTable({ name, newEntityData, oldEntityData, jsonSchema }) { const newTableOptions = newEntityData[0]?.tableOptions || {}; const oldTableOptions = oldEntityData[0]?.tableOptions || {}; @@ -764,6 +832,7 @@ module.exports = (baseProvider, options, app) => { return { name, + compMod: jsonSchema?.role?.compMod, tableOptions: { ...(isErrorTableModified && { ERROR_TABLE: newTableOptions.ERROR_TABLE }), ...(isForTableModified && { FOR_TABLE: newTableOptions.FOR_TABLE }), @@ -813,21 +882,11 @@ module.exports = (baseProvider, options, app) => { * @return {ModifyColumnData} */ hydrateAlterColumn({ newColumn, oldColumn, oldCompData, newCompData }) { - const diff = getDifferentProperties(newColumn, oldColumn, ['name', 'type']); - - const result = { ...newColumn }; - - if (oldCompData.name !== newCompData.name) { - result.oldName = oldCompData.name; - } - - if (oldCompData.type !== newCompData.type) { - result.oldType = oldCompData.type; - } - - if (!_.isEmpty(diff)) { - result.newOptions = diff; - } + const result = { + ...newColumn, + newProperties: newColumn, + oldProperties: oldColumn, + }; return result; }, @@ -861,10 +920,16 @@ module.exports = (baseProvider, options, app) => { entityData: oldEntityData, }); - const oldDViewData = {}; + const oldViewData = {}; + const newViewData = {}; if (oldEntityData[0]?.name !== newEntityData[0]?.name) { - oldDViewData.oldName = oldEntityData[0]?.name; + oldViewData.oldName = oldEntityData[0]?.name; + } + + if (oldEntityData[0]?.description !== newEntityData[0]?.description) { + oldViewData.oldDescription = oldEntityData[0]?.description; + newViewData.newDescription = newEntityData[0]?.description; } const options = getDifferentProperties(newData, oldData); @@ -875,7 +940,8 @@ module.exports = (baseProvider, options, app) => { selectStatement: options.selectStatement || newEntityData[0]?.selectStatement, recursive: options.recursive || newEntityData[0]?.recursive, options, - ...oldDViewData, + ...oldViewData, + ...newViewData, }; }, @@ -906,10 +972,22 @@ module.exports = (baseProvider, options, app) => { alterSchema(alterDbData) { const databaseOptions = getDatabaseOptions(alterDbData); - return assignTemplates(templates.modifyDatabase, { - databaseName: alterDbData.name, - databaseOptions, - }); + const databaseOptionScript = + databaseOptions && + assignTemplates(templates.modifyDatabase, { + databaseName: alterDbData.name, + databaseOptions, + }); + + const commentScript = + alterDbData.newDescription === alterDbData.oldDescription + ? '' + : assignTemplates(templates.commentDatabase, { + databaseName: prepareName(alterDbData.name), + comment: alterDbData.newDescription ? prepareComment(alterDbData.newDescription) : 'NULL', + }); + + return [databaseOptionScript, commentScript].filter(Boolean).join('\n\n'); }, /** @@ -918,7 +996,7 @@ module.exports = (baseProvider, options, app) => { */ dropTable(dropEntityData) { return assignTemplates(templates.dropTable, { - name: getTableName(dropEntityData.name, dropEntityData.dbName), + name: prepareName(dropEntityData.name, dropEntityData.dbName), temporary: dropEntityData.temporary ? 'TEMPORARY ' : '', }); }, @@ -930,17 +1008,38 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ alterTable(alterTableData, dbData) { - const tableName = getTableName(alterTableData.name, dbData.databaseName); + const tableName = prepareName(alterTableData.name, dbData.databaseName); const tableOptions = getTableOptions(alterTableData.tableOptions, true); + const { compMod } = alterTableData; - if (!_.trim(tableOptions)) { - return ''; - } + const oldName = prepareName(getOldName(alterTableData), dbData.databaseName); + const isNameChanged = oldName !== tableName; - return assignTemplates(templates.alterTable, { - tableName, - tableOptions, - }); + const renameStatement = isNameChanged + ? assignTemplates(templates.renameTable, { + newName: tableName, + oldName, + }) + : ''; + + const optionsStatement = _.trim(tableOptions) + ? assignTemplates(templates.alterTable, { + tableName, + tableOptions, + }) + : ''; + + const newComment = compMod?.description?.new; + const isCommentChanged = newComment !== compMod?.description?.old; + + const commentScript = isCommentChanged + ? assignTemplates(templates.commentTable, { + tableName, + comment: newComment ? prepareComment(newComment) : 'NULL', + }) + : ''; + + return [renameStatement, optionsStatement, commentScript].filter(Boolean).join('\n\n'); }, /** @@ -950,7 +1049,7 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ dropColumn(tableName, columnData, dbData) { - const fullTableName = getTableName(tableName, dbData.databaseName); + const fullTableName = prepareName(tableName, dbData.databaseName); return assignTemplates(templates.alterTable, { tableName: fullTableName, @@ -968,7 +1067,7 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ addColumn(tableName, columnDefinition, dbData) { - const table = getTableName(tableName, dbData.databaseName); + const table = prepareName(tableName, dbData.databaseName); return assignTemplates(templates.alterTable, { tableName: table, @@ -986,13 +1085,13 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ renameColumn(tableName, columnData, dbData) { - const table = getTableName(tableName, dbData.databaseName); + const table = prepareName(tableName, dbData.databaseName); return assignTemplates(templates.alterTable, { tableName: table, tableOptions: '', alterStatement: assignTemplates(templates.rename, { - oldName: wrap(columnData.oldName, '"', '"'), + oldName: wrap(columnData.oldProperties.name, '"', '"'), newName: wrap(columnData.name, '"', '"'), }), }); @@ -1005,35 +1104,59 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ alterColumn(tableName, columnData, dbData) { - const table = getTableName(tableName, dbData.databaseName); - let alterStatement = []; + const fullTableName = prepareName(tableName, dbData.databaseName); + const isNameChanged = columnData.newProperties.name !== columnData.oldProperties.name; + const isRequiredChanged = columnData.newProperties.required !== columnData.oldProperties.required; + const isDefaultChanged = columnData.newProperties.default !== columnData.oldProperties.default; + const newComment = columnData.newProperties.description; + const isCommentChanged = newComment !== columnData.oldProperties.description; + + const renameColumnStatement = isNameChanged ? this.renameColumn(tableName, columnData, dbData) : ''; + + const commentScript = isCommentChanged + ? assignTemplates(templates.commentColumn, { + columnName: `${fullTableName}.${prepareName(columnData.name)}`, + comment: newComment ? prepareComment(newComment) : 'NULL', + }) + : ''; - if ((columnData.oldName && columnData.oldType) || columnData.oldType) { - const dropOldColumnStatement = this.dropColumn(tableName, { name: columnData.name }, dbData); + let newColumnDefinition = []; - const createNewColumnStatement = this.addColumn( - tableName, - { ...columnData, isActivated: true }, - dbData, - ); + const newType = this.hasType(columnData.newProperties.type) + ? decorateType(columnData.newProperties.type, columnData.newProperties) + : columnData.newProperties.type; + + const oldType = this.hasType(columnData.oldProperties.type) + ? decorateType(columnData.oldProperties.type, columnData.oldProperties) + : columnData.oldProperties.type; + + if (newType !== oldType) { + newColumnDefinition.push(newType); + } + + if (isRequiredChanged) { + const nullScript = columnData.newProperties.required ? 'NOT NULL' : 'NULL'; + newColumnDefinition.push(nullScript); + } - alterStatement.push(dropOldColumnStatement, createNewColumnStatement); - } else if (columnData.oldName && !columnData.newOptions) { - const renameColumnStatement = this.renameColumn(tableName, columnData, dbData); - alterStatement.push(renameColumnStatement); - } else if (columnData.oldName && columnData.newOptions) { - const renameColumnStatement = this.renameColumn(tableName, columnData, dbData); - - // ADD "column_name"... statement in Teradata also used for modification column properties - const modifyColumnStatement = this.addColumn(tableName, { ...columnData, isActivated: true }, dbData); - alterStatement.push(renameColumnStatement, modifyColumnStatement); - } else { - // ADD "column_name"... statement in Teradata also used for modification column properties - const modifyColumnStatement = this.addColumn(tableName, { ...columnData, isActivated: true }, dbData); - alterStatement.push(modifyColumnStatement); + if (isDefaultChanged) { + const nullScript = `DEFAULT ${columnData.newProperties.default ?? 'NULL'}`; + newColumnDefinition.push(nullScript); } - return commentIfDeactivated(alterStatement.join('\n\n'), { isActivated: columnData.isActivated }); + // "ADD column_name" can be used to modify column properties + const updateColumnScript = newColumnDefinition.length + ? assignTemplates(templates.alterColumn, { + tableName: fullTableName, + columnName: prepareName(columnData.newProperties.name), + columnDefinition: newColumnDefinition.join(' '), + }) + : ''; + + return commentIfDeactivated( + [renameColumnStatement, updateColumnScript, commentScript].filter(Boolean).join('\n\n'), + { isActivated: columnData.isActivated }, + ); }, /** @@ -1047,7 +1170,7 @@ module.exports = (baseProvider, options, app) => { return ''; } - const table = getTableName(tableName, dbData.databaseName); + const table = prepareName(tableName, dbData.databaseName); if (['PRIMARY', 'PRIMARY AMP'].includes(indexData.indexType)) { return ''; @@ -1059,7 +1182,7 @@ module.exports = (baseProvider, options, app) => { } const indexType = indexData.indexType ? ` ${indexData.indexType}` : ''; - const indexName = getIndexName(indexData.indxName, dbData.databaseName); + const indexName = prepareName(indexData.indxName, dbData.databaseName); return assignTemplates(templates.dropIndex, { indexName, @@ -1094,7 +1217,7 @@ module.exports = (baseProvider, options, app) => { * @return {string} */ dropView({ name, dbData }) { - const viewName = getTableName(name, dbData.databaseName); + const viewName = prepareName(name, dbData.databaseName); return assignTemplates(templates.dropView, { viewName, @@ -1108,22 +1231,36 @@ module.exports = (baseProvider, options, app) => { */ alterView(alterData, dbData) { const isEmptyDiffOptions = _.isEmpty(alterData.options); - const viewName = getTableName(alterData.name, dbData.databaseName); + const viewName = prepareName(alterData.name, dbData.databaseName); - if (alterData.oldName && isEmptyDiffOptions) { - const oldViewName = getTableName(alterData.oldName, dbData.databaseName); - return assignTemplates(templates.renameView, { - oldViewName: oldViewName, - newViewName: viewName, - }); - } else if (isEmptyDiffOptions) { - return ''; + const renameView = alterData.oldName + ? assignTemplates(templates.renameView, { + oldViewName: prepareName(alterData.oldName, dbData.databaseName), + newViewName: viewName, + }) + : ''; + + const newComment = alterData.newDescription; + const isCommentChanged = newComment !== alterData.oldDescription; + + const commentScript = isCommentChanged + ? assignTemplates(templates.commentView, { + viewName, + comment: newComment ? prepareComment(newComment) : 'NULL', + }) + : ''; + + if (isEmptyDiffOptions) { + return [renameView, commentScript].filter(Boolean).join('\n\n'); } return [ this.dropView({ name: alterData.oldName || alterData.name, dbData }), this.createView(alterData, dbData, true), - ].join('\n\n'); + commentScript, + ] + .filter(Boolean) + .join('\n\n'); }, commentStatement(statement) { @@ -1131,7 +1268,74 @@ module.exports = (baseProvider, options, app) => { }, prepareName(name) { - return getTableName(name); + return prepareName(name); + }, + + alterCompositePrimaryKey({ schemaName, tableName, constraintName, columns, isActivated }) { + const fullTableName = prepareName(tableName, schemaName); + return commentIfDeactivated( + assignTemplates(templates.alterPrimaryKey, { + tableName: fullTableName, + constraintName: constraintName ? `CONSTRAINT ${prepareName(constraintName)} ` : '', + columns: columns.map(col => prepareName(col.name)).join(', '), + }), + { isActivated }, + ); + }, + + dropCompositePrimaryKey({ tableName, schemaName, constraintName, isActivated }) { + const fullTableName = prepareName(tableName, schemaName); + return commentIfDeactivated( + assignTemplates(templates.dropConstraint, { + tableName: fullTableName, + constraintName: prepareName(constraintName), + }), + { isActivated }, + ); + }, + + alterSinglePrimaryKey(params) { + return this.alterCompositePrimaryKey(params); + }, + + dropSinglePrimaryKey(params) { + return this.dropCompositePrimaryKey(params); + }, + + alterCompositeUniqueKey({ schemaName, tableName, constraintName, columns, isActivated }) { + const fullTableName = prepareName(tableName, schemaName); + return commentIfDeactivated( + assignTemplates(templates.alterUniqueKey, { + tableName: fullTableName, + constraintName: constraintName ? `CONSTRAINT ${prepareName(constraintName)} ` : '', + columns: columns.map(col => prepareName(col.name)).join(', '), + }), + { isActivated }, + ); + }, + + dropCompositeUniqueKey({ tableName, schemaName, constraintName, columns, isActivated }) { + const fullTableName = prepareName(tableName, schemaName); + + const script = constraintName + ? assignTemplates(templates.dropConstraint, { + tableName: fullTableName, + constraintName: prepareName(constraintName), + }) + : assignTemplates(templates.dropUnnamedIndex, { + tableName: fullTableName, + columns: columns.map(col => prepareName(col.name)).join(', '), + }); + + return commentIfDeactivated(script, { isActivated }); + }, + + alterSingleUniqueKey(params) { + return this.alterCompositeUniqueKey(params); + }, + + dropSingleUniqueKey(params) { + return this.dropCompositeUniqueKey(params); }, }); }; diff --git a/forward_engineering/helpers/constraintHelper.js b/forward_engineering/helpers/constraintHelper.js index 42dc11a..9da81fd 100644 --- a/forward_engineering/helpers/constraintHelper.js +++ b/forward_engineering/helpers/constraintHelper.js @@ -57,12 +57,12 @@ module.exports = ({ const columns = !isAllColumnsDeactivated && isParentActivated - ? ' (' + dividedColumns.activatedItems.join(', ') + deactivatedColumnsAsString + ')' - : ' (' + keyData.columns.map(columnMapToString).join(', ') + ')'; + ? dividedColumns.activatedItems.join(', ') + deactivatedColumnsAsString + : keyData.columns.map(columnMapToString).join(', '); return { statement: assignTemplates(templates.createKeyConstraint, { - constraintName: keyData.name ? `"${_.trim(keyData.name)}" ` : '', + constraintName: keyData.name ? `CONSTRAINT "${_.trim(keyData.name)}" ` : '', constraintType: keyData.keyType, columns, }), diff --git a/forward_engineering/helpers/general.js b/forward_engineering/helpers/general.js index 1209e0a..22b77ac 100644 --- a/forward_engineering/helpers/general.js +++ b/forward_engineering/helpers/general.js @@ -1,11 +1,29 @@ +const MUST_BE_ESCAPED = /[\t\n'\\\f\r]/gm; +const ESCAPE_MAP = { + '\n': '\\n', + '\t': '\\t', + '\r': '\\r', + '\f': '\\f', + '\\': '\\\\', + "'": "''", +}; + module.exports = (_, tab, commentIfDeactivated) => { + const prepareName = (entityName, databaseName) => { + if (databaseName) { + return `"${databaseName}"."${entityName}"`; + } else { + return `"${entityName}"`; + } + }; + const viewColumnsToString = (keys, isParentActivated) => { if (!isParentActivated) { - return keys.map(key => `"${key.name}"`).join(',\n\t'); + return keys.map(key => prepareName(key.alias || key.name)).join(',\n\t'); } - let activatedKeys = keys.filter(key => key.isActivated).map(key => `"${key.name}"`); - let deactivatedKeys = keys.filter(key => !key.isActivated).map(key => `"${key.name}"`); + let activatedKeys = keys.filter(key => key.isActivated).map(key => prepareName(key.alias || key.name)); + let deactivatedKeys = keys.filter(key => !key.isActivated).map(key => prepareName(key.alias || key.name)); if (activatedKeys.length === 0) { return commentIfDeactivated(deactivatedKeys.join(',\n\t'), { isActivated: false }, true); @@ -21,16 +39,6 @@ module.exports = (_, tab, commentIfDeactivated) => { ); }; - const getTableName = (tableName, databaseName) => { - if (databaseName) { - return `"${databaseName}"."${tableName}"`; - } else { - return `"${tableName}"`; - } - }; - - const getIndexName = getTableName; - const getDefaultJournalTableName = (dbName, tableName) => { if (dbName) { return `"${dbName}"."${tableName}"`; @@ -56,6 +64,7 @@ module.exports = (_, tab, commentIfDeactivated) => { db_default_map, db_permanent_storage_size, spool_files_size, + temporary_tables_size, has_fallback, db_before_journaling_strategy, db_after_journaling_strategy, @@ -63,17 +72,12 @@ module.exports = (_, tab, commentIfDeactivated) => { db_default_journal_db, dropDefaultJournalTable, }) => { - const add = - (condition, value, falsyValue = false) => - dbOptions => { - if (condition) { - return [...dbOptions, value]; - } else if (falsyValue) { - return [...dbOptions, falsyValue]; - } - - return dbOptions; - }; + const add = (condition, value) => dbOptions => { + if (condition) { + return [...dbOptions, value]; + } + return dbOptions; + }; const dropDefaultJournalTableStatement = dropDefaultJournalTable ? 'DROP ' : ''; const defaultJournalTableStatement = `${dropDefaultJournalTableStatement}DEFAULT JOURNAL TABLE = ${getDefaultJournalTableName(db_default_journal_db, db_default_journal_table)}`; @@ -81,28 +85,18 @@ module.exports = (_, tab, commentIfDeactivated) => { return _.flow([ add(db_permanent_storage_size, `PERMANENT = ${db_permanent_storage_size}`), add(spool_files_size, `SPOOL = ${spool_files_size}`), + add(temporary_tables_size, `TEMPORARY = ${temporary_tables_size}`), add(db_account, `ACCOUNT = ${db_account}`), add(db_default_map, `DEFAULT MAP = ${db_default_map}`), - add(has_fallback, 'FALLBACK', 'NO FALLBACK'), + add(has_fallback === true, 'FALLBACK'), + add(has_fallback === false, 'NO FALLBACK'), add(db_before_journaling_strategy, getJournalingStrategy(db_before_journaling_strategy, 'BEFORE')), add(db_after_journaling_strategy, getJournalingStrategy(db_after_journaling_strategy, 'AFTER')), add(db_default_journal_table, defaultJournalTableStatement), - dbOptions => tab('\n ' + dbOptions.join(',\n ')), + dbOptions => (dbOptions.length ? tab('\n ' + dbOptions.join(',\n ')) : ''), ])([]); }; - const getKeyWithAlias = key => { - if (!key) { - return ''; - } - - if (key.alias) { - return `"${key.name}" AS "${key.alias}"`; - } else { - return `"${key.name}"`; - } - }; - const getViewData = keys => { if (!Array.isArray(keys)) { return { tables: [], columns: [] }; @@ -110,20 +104,14 @@ module.exports = (_, tab, commentIfDeactivated) => { return keys.reduce( (result, key) => { - if (!key.tableName) { - result.columns.push(getKeyWithAlias(key)); - - return result; - } - - const tableName = `"${key.dbName}"."${key.tableName}"`; + const tableName = prepareName(key.tableName, key.dbName); if (!result.tables.includes(tableName)) { result.tables.push(tableName); } result.columns.push({ - statement: `${tableName}.${getKeyWithAlias(key)}`, + statement: `${tableName}.${prepareName(key.name)}`, isActivated: key.isActivated, }); @@ -149,14 +137,36 @@ module.exports = (_, tab, commentIfDeactivated) => { return Boolean(shouldDrop); }; + const prepareComment = (comment = '') => `'${comment.replaceAll(MUST_BE_ESCAPED, ch => ESCAPE_MAP[ch])}'`; + + const getName = entity => + entity.compMod?.code?.new || + entity.code || + entity.compMod?.collectionName?.new || + entity.collectionName || + entity.compMod?.name?.new || + entity.name || + ''; + + const getOldName = entity => + entity.compMod?.code?.old || + entity.code || + entity.compMod?.collectionName?.old || + entity.collectionName || + entity.compMod?.name?.old || + entity.name || + ''; + return { - getTableName, - getIndexName, + prepareName, getJournalingStrategy, getDefaultJournalTableName, getDatabaseOptions, getViewData, viewColumnsToString, shouldDropDefaultJournalTable, + prepareComment, + getName, + getOldName, }; }; diff --git a/forward_engineering/helpers/tableHelper.js b/forward_engineering/helpers/tableHelper.js index a92df5b..482ef0a 100644 --- a/forward_engineering/helpers/tableHelper.js +++ b/forward_engineering/helpers/tableHelper.js @@ -229,8 +229,6 @@ module.exports = ({ _, tab, getJournalingStrategy, commentIfDeactivated, divideI return commentIfDeactivated(indexStatement, { isActivated }); }; - const getTableInlineIndexStatements = tableIndexes => tableIndexes.map(getTableInlineIndexStatement); - const findPrimaryIndex = indexes => { const primaryIndex = indexes.find( index => ['PRIMARY', 'PRIMARY AMP'].includes(index.indexType) && !_.isEmpty(index.indxKey), @@ -241,13 +239,8 @@ module.exports = ({ _, tab, getJournalingStrategy, commentIfDeactivated, divideI return {}; }; - const filterSecondaryIndexes = indexes => - indexes.filter(index => (!index.indexType || index.indexType === 'SECONDARY') && !_.isEmpty(index.indxKey)); - const getPrimaryIndex = _.flow([findPrimaryIndex, getTableInlineIndexStatement]); - const getSecondaryIndexes = _.flow([filterSecondaryIndexes, getTableInlineIndexStatements, _.compact]); - const getPartitionKeys = compositePartitionKeys => { return compositePartitionKeys.map(key => { let keyStatement = ''; @@ -278,17 +271,16 @@ module.exports = ({ _, tab, getJournalingStrategy, commentIfDeactivated, divideI _.isEmpty(tableData.partitioning.compositePartitionKey) ? '' : getPartitions(tableData.partitioning); - const secondaryIndexes = getSecondaryIndexes(tableData.tableIndexes || []); - if (!primaryIndex && !partitions && _.isEmpty(secondaryIndexes)) { + if (!primaryIndex && !partitions) { return ''; } let primaryIndexStatement = ''; - primaryIndexStatement += primaryIndex ? primaryIndex : ''; + primaryIndexStatement += primaryIndex || ''; primaryIndexStatement += partitions ? '\n' + partitions : ''; - return '\n' + tab([primaryIndexStatement, ...secondaryIndexes].filter(Boolean).join(',\n')); + return '\n' + tab([primaryIndexStatement].filter(Boolean).join(',\n')); }; const getUsingOptions = ({ @@ -324,5 +316,6 @@ module.exports = ({ _, tab, getJournalingStrategy, commentIfDeactivated, divideI getInlineTableIndexes, getIndexOptions, getIndexKeys, + getTableInlineIndexStatement, }; }; diff --git a/localization/en.json b/localization/en.json index 6b15660..15fbc29 100644 --- a/localization/en.json +++ b/localization/en.json @@ -178,5 +178,7 @@ "CUSTOM_SCRIPT_CONTAINER_VAR_NAME": "Database name", "CUSTOM_SCRIPT_CONTAINER_VAR": "databaseName", "CUSTOM_SCRIPT_ENTITY_VAR_NAME": "Table name", - "CUSTOM_SCRIPT_ENTITY_VAR": "tableName" + "CUSTOM_SCRIPT_ENTITY_VAR": "tableName", + + "FE_SCRIPT_GENERATION_OPTIONS___SCHEMA_COMMENTS": "Database comments" } diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index ed0530c..2f6c584 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -160,7 +160,20 @@ making sure that you maintain a proper JSON format. "propertyName": "Error table", "propertyKeyword": "ERROR_TABLE", "propertyType": "checkbox", - "defaultValue": false + "defaultValue": false, + "dependency": { + "type": "or", + "values": [ + { + "key": "FOREIGN_TABLE", + "exist": false + }, + { + "key": "FOREIGN_TABLE", + "value": false + } + ] + } }, { "propertyName": "For", @@ -293,13 +306,12 @@ making sure that you maintain a proper JSON format. "propertyName": "Log", "propertyKeyword": "LOG", "propertyType": "checkbox", - "defaultValue": "false" + "defaultValue": true }, { "propertyName": "BEFORE Journal", "propertyKeyword": "BEFORE_JOURNAL", "propertyType": "select", - "defaultValue": "NO", "options": ["NO", "BEFORE", "DUAL"] }, { @@ -307,7 +319,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "AFTER_JOURNAL", "propertyType": "select", "propertyTooltip": "Type of journal to be maintained by default for data tables created in the new database. The JOURNAL keyword without AFTER implies BEFORE and AFTER images.", - "defaultValue": "NO", "options": ["NO", "AFTER", "DUAL", "LOCAL", "NO LOCAL"] }, {