From 227d95b4390c81d6248c19f6a855211e29896946 Mon Sep 17 00:00:00 2001 From: chulanovskyi-bs Date: Wed, 21 Oct 2026 15:18:56 +0300 Subject: [PATCH] feat: snowflake pk/uk comments --- adapter/0.2.64.json | 77 ++ forward_engineering/api/generateScript.js | 3 +- forward_engineering/ddlProvider.js | 114 +-- .../helpers/alterScriptFromDeltaHelper.js | 15 +- .../alterScriptHelpers/alterEntityHelper.js | 14 +- .../entityHelper/primaryKeyHelper.js | 5 +- .../entityHelper/sharedKeyConstraintHelper.js | 121 ++- .../entityHelper/uniqueKeyHelper.js | 5 +- forward_engineering/helpers/constants.js | 11 +- .../helpers/constraintHelper.js | 21 +- forward_engineering/helpers/keyHelper.js | 49 +- package-lock.json | 6 +- package.json | 6 +- polyglot/adapter.json | 32 +- .../entity_level/entityLevelConfig.json | 16 + .../field_level/fieldLevelConfig.json | 700 +++++++++++++++--- 16 files changed, 942 insertions(+), 253 deletions(-) create mode 100644 adapter/0.2.64.json diff --git a/adapter/0.2.64.json b/adapter/0.2.64.json new file mode 100644 index 00000000..f10c3098 --- /dev/null +++ b/adapter/0.2.64.json @@ -0,0 +1,77 @@ +/** + * Copyright © 2016-2026 by IntegrIT S.A. dba Hackolade. All rights reserved. + * + * The copyright to the computer software herein is the property of IntegrIT S.A. + * The software may be used and/or copied only with the written permission of + * IntegrIT S.A. or in accordance with the terms and conditions stipulated in + * the agreement/contract under which the software has been supplied. + * + * { + * "add": { + * "entity": [], + * "container": [], + * "model": [], + * "view": [], + * "field": { + * "": [] + * } + * }, + * "delete": { + * "entity": [], + * "container": [], + * "model": [], + * "view": [], + * "field": { + * "": [] + * } + * }, + * "modify": { + * "entity": [ + * { + * "from": { }, + * "to": { } + * } + * ], + * "container": [], + * "model": [], + * "view": [], + * "field": [] + * }, + * } + */ +{ + "modify": { + "field": [ + [ + "movePropertyByPath", + { + "from": "primaryKeyConstraintName", + "to": "primaryKeyOptions.constraintName" + } + ], + [ + "addMissingIdByPath", + { + "from": "primaryKeyOptions", + "path": "primaryKeyOptions.GUID" + } + ], + ["convertBlockPropertyToGroupProperty", "primaryKeyOptions"], + [ + "movePropertyByPath", + { + "from": "uniqueKeyConstraintName", + "to": "uniqueKeyOptions.constraintName" + } + ], + [ + "addMissingIdByPath", + { + "from": "uniqueKeyOptions", + "path": "uniqueKeyOptions.GUID" + } + ], + ["convertBlockPropertyToGroupProperty", "uniqueKeyOptions"] + ] + } +} diff --git a/forward_engineering/api/generateScript.js b/forward_engineering/api/generateScript.js index 011a60ef..5aea4353 100644 --- a/forward_engineering/api/generateScript.js +++ b/forward_engineering/api/generateScript.js @@ -1,4 +1,5 @@ const _ = require('lodash'); +const { FORMATS } = require('../helpers/constants'); const { commentDropStatements } = require('../helpers/commentHelpers/commentDropStatements.js'); const { getAlterScript } = require('../helpers/alterScriptFromDeltaHelper.js'); @@ -14,7 +15,7 @@ function generateScript(data, logger, callback, app) { ); } - const scriptFormat = _.get(data, 'options.targetScriptOptions.keyword'); + const scriptFormat = _.get(data, 'options.targetScriptOptions.keyword') || FORMATS.SNOWSIGHT; const script = getAlterScript({ scriptFormat, collection, ddlProvider, app, options: data.options }); const applyDropStatements = data.options?.additionalOptions?.some( diff --git a/forward_engineering/ddlProvider.js b/forward_engineering/ddlProvider.js index 5ddff6ec..d514b72e 100644 --- a/forward_engineering/ddlProvider.js +++ b/forward_engineering/ddlProvider.js @@ -674,8 +674,29 @@ module.exports = (baseProvider, options, app) => { }, hydrateColumn({ columnDefinition, jsonSchema, dbData }) { - const pkConstraintName = jsonSchema.compositePrimaryKey ? undefined : jsonSchema.primaryKeyConstraintName; - const ukConstraintName = jsonSchema.compositeUniqueKey ? undefined : jsonSchema.uniqueKeyConstraintName; + const readKey = (optionsKey, flatNameKey) => { + const optionsList = jsonSchema?.[optionsKey]; + const options = Array.isArray(optionsList) ? optionsList[0] : optionsList; + + return { + name: options?.constraintName || jsonSchema?.[flatNameKey] || '', + comment: options?.indexComment || '', + }; + }; + + const primaryKey = readKey('primaryKeyOptions', 'primaryKeyConstraintName'); + const uniqueKey = readKey('uniqueKeyOptions', 'uniqueKeyConstraintName'); + + const pkOutOfLine = Boolean( + !jsonSchema.compositePrimaryKey && jsonSchema.primaryKey && (primaryKey.name || primaryKey.comment), + ); + + const ukOutOfLine = Boolean( + !jsonSchema.compositeUniqueKey && jsonSchema.unique && (uniqueKey.name || uniqueKey.comment), + ); + + const pkConstraintName = jsonSchema.compositePrimaryKey ? undefined : primaryKey.name || undefined; + const ukConstraintName = jsonSchema.compositeUniqueKey ? undefined : uniqueKey.name || undefined; return { ...columnDefinition, @@ -708,12 +729,14 @@ module.exports = (baseProvider, options, app) => { }) : {}, comment: jsonSchema.refDescription || jsonSchema.description, - unique: jsonSchema.uniqueKeyConstraintName ? false : jsonSchema.unique, + unique: ukOutOfLine ? false : jsonSchema.unique, primaryKeyConstraintName: pkConstraintName, - compositePrimaryKey: jsonSchema.compositePrimaryKey || (pkConstraintName && jsonSchema.primaryKey), - compositeUniqueKey: jsonSchema.compositeUniqueKey || (ukConstraintName && jsonSchema.unique), + primaryKeyComment: primaryKey.comment || undefined, + compositePrimaryKey: jsonSchema.compositePrimaryKey || pkOutOfLine, + compositeUniqueKey: jsonSchema.compositeUniqueKey || ukOutOfLine, uniqueKeyConstraintName: ukConstraintName, - primaryKey: jsonSchema.primaryKeyConstraintName ? false : columnDefinition.primaryKey, + uniqueKeyComment: uniqueKey.comment || undefined, + primaryKey: pkOutOfLine ? false : columnDefinition.primaryKey, expression: jsonSchema.expression, columnTags: jsonSchema.columnTags ?? [], }; @@ -851,12 +874,29 @@ module.exports = (baseProvider, options, app) => { const keyConstraints = keyHelper.getTableKeyConstraints({ jsonSchema }); - const entityLevelCompositeKeysReducer = (keys, data) => ({ - ...keys, - [data.name]: data.columns.map(column => { - return { name: column.name, isActivated: column.isActivated }; - }), - }); + const mergeOutOfLineKey = (keys, { name = '', columns, comment = '' }) => { + const groupKey = name || `unnamed:${columns.map(column => column.name).join(',')}`; + const existing = keys[groupKey]; + + return { + ...keys, + [groupKey]: { + name, + columns: existing ? uniqBy([...existing.columns, ...columns], 'name') : columns, + comment: comment || existing?.comment || '', + }, + }; + }; + + const entityLevelCompositeKeysReducer = (keys, data) => + mergeOutOfLineKey(keys, { + name: data.name || '', + columns: (data.columns || []).map(column => ({ + name: column.name, + isActivated: column.isActivated, + })), + comment: data.comment || '', + }); const entityLevelCompositePrimaryKeys = keyConstraints .filter(({ keyType }) => keyType === 'PRIMARY KEY') @@ -869,43 +909,29 @@ module.exports = (baseProvider, options, app) => { const compositePrimaryKeys = tableData.columnDefinitions .filter(column => column.compositePrimaryKey) .reduce((result, column) => { - if (!column.primaryKeyConstraintName) { + if (!column.primaryKeyConstraintName && !column.primaryKeyComment) { return result; } - return { - ...result, - [column.primaryKeyConstraintName]: Array.isArray(result[column.primaryKeyConstraintName]) - ? uniqBy( - [ - ...result[column.primaryKeyConstraintName], - { name: column.name, isActivated: column.isActivated }, - ], - 'name', - ) - : [{ name: column.name, isActivated: column.isActivated }], - }; + return mergeOutOfLineKey(result, { + name: column.primaryKeyConstraintName || '', + columns: [{ name: column.name, isActivated: column.isActivated }], + comment: column.primaryKeyComment || '', + }); }, entityLevelCompositePrimaryKeys); const compositeUniqueKeys = tableData.columnDefinitions .filter(column => column.compositeUniqueKey) .reduce((result, column) => { - if (!column.uniqueKeyConstraintName) { + if (!column.uniqueKeyConstraintName && !column.uniqueKeyComment) { return result; } - return { - ...result, - [column.uniqueKeyConstraintName]: Array.isArray(result[column.uniqueKeyConstraintName]) - ? uniqBy( - [ - ...result[column.uniqueKeyConstraintName], - { name: column.name, isActivated: column.isActivated }, - ], - 'name', - ) - : [{ name: column.name, isActivated: column.isActivated }], - }; + return mergeOutOfLineKey(result, { + name: column.uniqueKeyConstraintName || '', + columns: [{ name: column.name, isActivated: column.isActivated }], + comment: column.uniqueKeyComment || '', + }); }, entityLevelCompositeUniqueKeys); return { @@ -990,19 +1016,23 @@ module.exports = (baseProvider, options, app) => { columns: firstTab.external ? tableData.columnDefinitions.map(createExternalColumn(scriptFormat)) : tableData.columns, - compositePrimaryKeys: Object.entries(compositePrimaryKeys).map(([name, keys]) => + compositePrimaryKeys: Object.values(compositePrimaryKeys).map(({ name, columns, comment }) => generateConstraint({ name, - keys, + keys: columns, + comment, + scriptFormat, keyType: 'PRIMARY KEY', isActivated: jsonSchema.isActivated, isCaseSensitive: firstTab.isCaseSensitive, }), ), - compositeUniqueKeys: Object.entries(compositeUniqueKeys).map(([name, keys]) => + compositeUniqueKeys: Object.values(compositeUniqueKeys).map(({ name, columns, comment }) => generateConstraint({ name, - keys, + keys: columns, + comment, + scriptFormat, keyType: 'UNIQUE', isActivated: jsonSchema.isActivated, isCaseSensitive: firstTab.isCaseSensitive, diff --git a/forward_engineering/helpers/alterScriptFromDeltaHelper.js b/forward_engineering/helpers/alterScriptFromDeltaHelper.js index 39f789fb..3a34eee9 100644 --- a/forward_engineering/helpers/alterScriptFromDeltaHelper.js +++ b/forward_engineering/helpers/alterScriptFromDeltaHelper.js @@ -40,7 +40,13 @@ const getAlterContainersScripts = (collection, ddlProvider, app) => { return { addedContainerScripts, deletedContainerScripts, modifiedContainerScripts }; }; -const getAlterCollectionsScripts = ({ collection, ddlProvider, app, scriptFormat, shouldIgnoreColumnComments = false }) => { +const getAlterCollectionsScripts = ({ + collection, + ddlProvider, + app, + scriptFormat, + shouldIgnoreColumnComments = false, +}) => { const getCollectionScripts = (items, compMode, getScript) => items.filter(item => item.compMod?.[compMode]).map(getScript); @@ -63,7 +69,9 @@ const getAlterCollectionsScripts = ({ collection, ddlProvider, app, scriptFormat 'modified', getModifyCollectionScript(ddlProvider), ); - const modifyCollectionKeysScripts = modifiedItems.flatMap(getModifyCollectionKeysScript); + const modifyCollectionKeysScripts = modifiedItems.flatMap(item => + getModifyCollectionKeysScript(item, scriptFormat), + ); const addedColumnScripts = getColumnScripts( getItems(collection, 'entities', 'added', 'values'), @@ -184,8 +192,7 @@ const getAlterForeignKeysScripts = ({ collection, ddlProvider }) => { }; const getAlterScript = ({ scriptFormat, collection, ddlProvider, app, options }) => { - const shouldIgnoreColumnComments = - options?.scriptGenerationOptions?.feActiveOptions?.columnComments === 'ignore'; + const shouldIgnoreColumnComments = options?.scriptGenerationOptions?.feActiveOptions?.columnComments === 'ignore'; const script = { ...getAlterCollectionsScripts({ collection, diff --git a/forward_engineering/helpers/alterScriptHelpers/alterEntityHelper.js b/forward_engineering/helpers/alterScriptHelpers/alterEntityHelper.js index 14cd075d..cbfb40a6 100644 --- a/forward_engineering/helpers/alterScriptHelpers/alterEntityHelper.js +++ b/forward_engineering/helpers/alterScriptHelpers/alterEntityHelper.js @@ -93,8 +93,7 @@ const getAddColumnScript = scriptFormat, }); const column = ddlProvider.convertColumnDefinition(columnDefinition); - const isActivated = - isContainerActivated && isCollectionActivated && jsonSchema.isActivated !== false; + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated !== false; const addColumnScript = `ALTER TABLE IF EXISTS ${fullName} ADD COLUMN ${commentIfDeactivated(column.statement, { isActivated })};`; const commentScript = getAddedCommentOnColumnScript({ collection, @@ -223,9 +222,14 @@ const getModifyColumnScript = ]; }; -const getModifyCollectionKeysScript = collection => { - const modifyPkScriptDtos = getModifyPkScripts(collection); - const modifyUkScriptDtos = getModifyUkScripts(collection); +/** + * @param {AlterCollectionDto} collection + * @param {string} scriptFormat + * @return {string[]} + */ +const getModifyCollectionKeysScript = (collection, scriptFormat) => { + const modifyPkScriptDtos = getModifyPkScripts(collection, scriptFormat); + const modifyUkScriptDtos = getModifyUkScripts(collection, scriptFormat); const allScriptDtos = [...modifyPkScriptDtos, ...modifyUkScriptDtos]; diff --git a/forward_engineering/helpers/alterScriptHelpers/entityHelper/primaryKeyHelper.js b/forward_engineering/helpers/alterScriptHelpers/entityHelper/primaryKeyHelper.js index 49a24db6..2523717b 100644 --- a/forward_engineering/helpers/alterScriptHelpers/entityHelper/primaryKeyHelper.js +++ b/forward_engineering/helpers/alterScriptHelpers/entityHelper/primaryKeyHelper.js @@ -15,10 +15,11 @@ const PRIMARY_KEY_CONFIG = { * Get all modify PK scripts (both composite and regular) * * @param {AlterCollectionDto} collection + * @param {string} scriptFormat * @return {AlterScriptDto[]} * */ -const getModifyPkScripts = collection => { - return getModifyKeyScripts(collection, PRIMARY_KEY_CONFIG); +const getModifyPkScripts = (collection, scriptFormat) => { + return getModifyKeyScripts(collection, PRIMARY_KEY_CONFIG, scriptFormat); }; module.exports = { diff --git a/forward_engineering/helpers/alterScriptHelpers/entityHelper/sharedKeyConstraintHelper.js b/forward_engineering/helpers/alterScriptHelpers/entityHelper/sharedKeyConstraintHelper.js index 16228756..facd5527 100644 --- a/forward_engineering/helpers/alterScriptHelpers/entityHelper/sharedKeyConstraintHelper.js +++ b/forward_engineering/helpers/alterScriptHelpers/entityHelper/sharedKeyConstraintHelper.js @@ -17,6 +17,25 @@ const templates = require('../../../configs/templates'); const amountOfColumnsInRegularKey = 1; +const optionsKeyByConstraintName = { + primaryKeyConstraintName: 'primaryKeyOptions', + uniqueKeyConstraintName: 'uniqueKeyOptions', +}; + +const getRegularKeyData = (jsonSchema, config) => { + const optionsList = jsonSchema?.[optionsKeyByConstraintName[config.constraintNameProperty]]; + const options = Array.isArray(optionsList) ? optionsList[0] : optionsList; + + return { + constraintName: options?.constraintName || jsonSchema?.[config.constraintNameProperty] || '', + indexComment: options?.indexComment || '', + }; +}; + +const areKeyDefinitionsEqual = (left, right) => + areConstraintNamesEqual(left.constraintName || '', right.constraintName || '') && + (left.indexComment || '') === (right.indexComment || ''); + /** * Configuration object for key constraint handling * @typedef {Object} KeyConstraintConfig @@ -82,17 +101,22 @@ const wasCompositeKeyChangedInTransitionFromCompositeToRegular = (collection, co return PrimaryKeyTransitionDto.noTransition(); } - // In Snowflake, compare only constraint names - const newConstraintName = newColumnJsonSchema[config.constraintNameProperty] || ''; - const areNamesEqual = oldKeys.some(compositeKey => { + const newKey = getRegularKeyData(newColumnJsonSchema, config); + const areDefinitionsEqual = oldKeys.some(compositeKey => { if (compositeKey[config.compositeKeyProperty]?.length !== amountOfColumnsInRegularKey) { return false; } - const oldConstraintName = compositeKey.constraintName || ''; - return areConstraintNamesEqual(oldConstraintName, newConstraintName); + + return areKeyDefinitionsEqual( + { + constraintName: compositeKey.constraintName || '', + indexComment: compositeKey.indexComment || '', + }, + newKey, + ); }); - return PrimaryKeyTransitionDto.transition(!areNamesEqual); + return PrimaryKeyTransitionDto.transition(!areDefinitionsEqual); }; /** @@ -125,25 +149,29 @@ const wasCompositeKeyChangedInTransitionFromRegularToComposite = (collection, co return PrimaryKeyTransitionDto.noTransition(); } - const oldConstraintName = oldColumnJsonSchema[config.constraintNameProperty] || ''; - const areNamesEqual = newKeys.some(compositeKey => { + const oldKey = getRegularKeyData(oldColumnJsonSchema, config); + const areDefinitionsEqual = newKeys.some(compositeKey => { if (compositeKey[config.compositeKeyProperty]?.length !== amountOfColumnsInRegularKey) { return false; } - const newConstraintName = compositeKey.constraintName || ''; - return areConstraintNamesEqual(oldConstraintName, newConstraintName); + + return areKeyDefinitionsEqual(oldKey, { + constraintName: compositeKey.constraintName || '', + indexComment: compositeKey.indexComment || '', + }); }); - return PrimaryKeyTransitionDto.transition(!areNamesEqual); + return PrimaryKeyTransitionDto.transition(!areDefinitionsEqual); }; /** * Get ADD CONSTRAINT scripts for composite keys * @param {AlterCollectionDto} collection * @param {KeyConstraintConfig} config + * @param {string} scriptFormat * @return {Array} */ -const getAddCompositeKeyScriptDtos = (collection, config) => { +const getAddCompositeKeyScriptDtos = (collection, config, scriptFormat) => { const keyDto = collection?.role?.compMod?.[config.compModKeyName] || {}; const newKeys = keyDto.new || []; const oldKeys = keyDto.old || []; @@ -187,6 +215,8 @@ const getAddCompositeKeyScriptDtos = (collection, config) => { const { statement } = generateConstraint({ name: newKey.constraintName, keys: columns, + comment: newKey.indexComment, + scriptFormat, keyType: config.constraintType, isParentActivated: true, isCaseSensitive, @@ -278,11 +308,12 @@ const getDropCompositeKeyScriptDtos = (collection, config) => { * Get modify scripts for composite keys (drop + add) * @param {AlterCollectionDto} collection * @param {KeyConstraintConfig} config + * @param {string} scriptFormat * @return {Array} */ -const getModifyCompositeKeyScriptDtos = (collection, config) => { +const getModifyCompositeKeyScriptDtos = (collection, config, scriptFormat) => { const dropCompositeKeyScriptDtos = getDropCompositeKeyScriptDtos(collection, config); - const addCompositeKeyScriptDtos = getAddCompositeKeyScriptDtos(collection, config); + const addCompositeKeyScriptDtos = getAddCompositeKeyScriptDtos(collection, config, scriptFormat); return [...dropCompositeKeyScriptDtos, ...addCompositeKeyScriptDtos].filter(Boolean); }; @@ -339,10 +370,10 @@ const wasRegularKeyModified = (columnJsonSchema, collection, config) => { return false; } - const oldConstraintName = oldJsonSchema[config.constraintNameProperty] || ''; - const newConstraintName = columnJsonSchema[config.constraintNameProperty] || ''; - - return !areConstraintNamesEqual(oldConstraintName, newConstraintName); + return !areKeyDefinitionsEqual( + getRegularKeyData(oldJsonSchema, config), + getRegularKeyData(columnJsonSchema, config), + ); }; /** @@ -377,16 +408,21 @@ const wasRegularKeyChangedInTransitionFromCompositeToRegular = (columnJsonSchema const wasCompositeKeyRemoved = wasTheFieldACompositeKey && !isTheFieldACompositeKey; if (isRegularKey && wasCompositeKeyRemoved) { - // In Snowflake, only compare constraint names - const newConstraintName = columnJsonSchema[config.constraintNameProperty] || ''; - const areNamesEqual = oldKeys.some(oldCompositeKey => { + const newKey = getRegularKeyData(columnJsonSchema, config); + const areDefinitionsEqual = oldKeys.some(oldCompositeKey => { if (oldCompositeKey[config.compositeKeyProperty]?.length !== amountOfColumnsInRegularKey) { return false; } - const oldConstraintName = oldCompositeKey.constraintName || ''; - return areConstraintNamesEqual(oldConstraintName, newConstraintName); + + return areKeyDefinitionsEqual( + { + constraintName: oldCompositeKey.constraintName || '', + indexComment: oldCompositeKey.indexComment || '', + }, + newKey, + ); }); - return PrimaryKeyTransitionDto.transition(!areNamesEqual); + return PrimaryKeyTransitionDto.transition(!areDefinitionsEqual); } return PrimaryKeyTransitionDto.noTransition(); @@ -425,16 +461,18 @@ const wasRegularKeyChangedInTransitionFromRegularToComposite = (columnJsonSchema const wasCompositeKeyAdded = isTheFieldACompositeKey && !wasTheFieldACompositeKey; if (wasRegularKey && wasCompositeKeyAdded) { - // In Snowflake, only compare constraint names - const oldConstraintName = oldColumnJsonSchema[config.constraintNameProperty] || ''; - const areNamesEqual = newKeys.some(newCompositeKey => { + const oldKey = getRegularKeyData(oldColumnJsonSchema, config); + const areDefinitionsEqual = newKeys.some(newCompositeKey => { if (newCompositeKey[config.compositeKeyProperty]?.length !== amountOfColumnsInRegularKey) { return false; } - const newConstraintName = newCompositeKey.constraintName || ''; - return areConstraintNamesEqual(oldConstraintName, newConstraintName); + + return areKeyDefinitionsEqual(oldKey, { + constraintName: newCompositeKey.constraintName || '', + indexComment: newCompositeKey.indexComment || '', + }); }); - return PrimaryKeyTransitionDto.transition(!areNamesEqual); + return PrimaryKeyTransitionDto.transition(!areDefinitionsEqual); } return PrimaryKeyTransitionDto.noTransition(); @@ -444,9 +482,10 @@ const wasRegularKeyChangedInTransitionFromRegularToComposite = (columnJsonSchema * Get ADD CONSTRAINT scripts for regular (column-level) keys * @param {AlterCollectionDto} collection * @param {KeyConstraintConfig} config + * @param {string} scriptFormat * @return {Array} */ -const getAddRegularKeyScriptDtos = (collection, config) => { +const getAddRegularKeyScriptDtos = (collection, config, scriptFormat) => { const collectionSchema = { ...collection, ..._.omit(collection?.role, 'properties') }; const { schemaName, databaseName, tableName } = getNames(collectionSchema, getName, getEntityName); const fullName = getFullName(databaseName, getFullName(schemaName, tableName)); @@ -472,10 +511,13 @@ const getAddRegularKeyScriptDtos = (collection, config) => { }) .map(([name, jsonSchema]) => { const columns = [{ name, isActivated: jsonSchema.isActivated }]; + const keyData = getRegularKeyData(jsonSchema, config); const { statement } = generateConstraint({ - name: jsonSchema[config.constraintNameProperty], + name: keyData.constraintName, keys: columns, + comment: keyData.indexComment, + scriptFormat, keyType: config.constraintType, isParentActivated: true, isCaseSensitive, @@ -523,9 +565,10 @@ const getDropRegularKeyScriptDtos = (collection, config) => { .map(([name, jsonSchema]) => { const oldName = jsonSchema.compMod.oldField.name; const oldJsonSchema = collection.role.properties[oldName]; + const oldKey = getRegularKeyData(oldJsonSchema, config); const { statement } = generateConstraint({ - name: getName(isCaseSensitive, oldJsonSchema[config.constraintNameProperty]), + name: getName(isCaseSensitive, oldKey.constraintName), keys: [{ name, isActivated: true }], keyType: config.constraintType, isParentActivated: true, @@ -545,11 +588,12 @@ const getDropRegularKeyScriptDtos = (collection, config) => { * Get modify scripts for regular keys (drop + add) * @param {AlterCollectionDto} collection * @param {KeyConstraintConfig} config + * @param {string} scriptFormat * @return {Array} */ -const getModifyRegularKeyScriptDtos = (collection, config) => { +const getModifyRegularKeyScriptDtos = (collection, config, scriptFormat) => { const dropKeyScriptDtos = getDropRegularKeyScriptDtos(collection, config); - const addKeyScriptDtos = getAddRegularKeyScriptDtos(collection, config); + const addKeyScriptDtos = getAddRegularKeyScriptDtos(collection, config, scriptFormat); return [...dropKeyScriptDtos, ...addKeyScriptDtos].filter(Boolean); }; @@ -576,11 +620,12 @@ const sortModifyKeyConstraints = constraintDtos => { * * @param {AlterCollectionDto} collection * @param {KeyConstraintConfig} config + * @param {string} scriptFormat * @return {AlterScriptDto[]} * */ -const getModifyKeyScripts = (collection, config) => { - const modifyCompositeKeyScriptDtos = getModifyCompositeKeyScriptDtos(collection, config); - const modifyRegularKeyScriptDtos = getModifyRegularKeyScriptDtos(collection, config); +const getModifyKeyScripts = (collection, config, scriptFormat) => { + const modifyCompositeKeyScriptDtos = getModifyCompositeKeyScriptDtos(collection, config, scriptFormat); + const modifyRegularKeyScriptDtos = getModifyRegularKeyScriptDtos(collection, config, scriptFormat); const allDtos = [...modifyCompositeKeyScriptDtos, ...modifyRegularKeyScriptDtos]; const sortedAllDtos = sortModifyKeyConstraints(allDtos); diff --git a/forward_engineering/helpers/alterScriptHelpers/entityHelper/uniqueKeyHelper.js b/forward_engineering/helpers/alterScriptHelpers/entityHelper/uniqueKeyHelper.js index 2d6a01ff..dbc0ace1 100644 --- a/forward_engineering/helpers/alterScriptHelpers/entityHelper/uniqueKeyHelper.js +++ b/forward_engineering/helpers/alterScriptHelpers/entityHelper/uniqueKeyHelper.js @@ -15,10 +15,11 @@ const UNIQUE_KEY_CONFIG = { * Get all modify UK scripts (both composite and regular) * * @param {AlterCollectionDto} collection + * @param {string} scriptFormat * @return {AlterScriptDto[]} * */ -const getModifyUkScripts = collection => { - return getModifyKeyScripts(collection, UNIQUE_KEY_CONFIG); +const getModifyUkScripts = (collection, scriptFormat) => { + return getModifyKeyScripts(collection, UNIQUE_KEY_CONFIG, scriptFormat); }; module.exports = { diff --git a/forward_engineering/helpers/constants.js b/forward_engineering/helpers/constants.js index 0beb2f67..32889e74 100644 --- a/forward_engineering/helpers/constants.js +++ b/forward_engineering/helpers/constants.js @@ -1,4 +1,13 @@ -const DROP_STATEMENTS = ['DROP SCHEMA', 'DROP TABLE', 'DROP COLUMN', 'DROP VIEW', 'DROP TAG']; +const DROP_STATEMENTS = [ + 'DROP SCHEMA', + 'DROP TABLE', + 'DROP COLUMN', + 'DROP VIEW', + 'DROP TAG', + 'DROP CONSTRAINT', + 'DROP PRIMARY KEY', + 'DROP UNIQUE', +]; const LANGUAGES = { JAVA: 'java', diff --git a/forward_engineering/helpers/constraintHelper.js b/forward_engineering/helpers/constraintHelper.js index 61f5997e..391bcd9e 100644 --- a/forward_engineering/helpers/constraintHelper.js +++ b/forward_engineering/helpers/constraintHelper.js @@ -1,6 +1,19 @@ const { foreignKeysToString, foreignActiveKeysToString, getName } = require('./general'); +const { escapeString } = require('../utils/escapeString'); -const generateConstraint = ({ name, keys, keyType, isParentActivated, isCaseSensitive }) => { +/** + * @param {{ + * name: string, + * keys: Array<{ name: string, isActivated: boolean }>, + * keyType: string, + * isParentActivated: boolean, + * isCaseSensitive?: boolean, + * comment?: string, + * scriptFormat?: string, + * }} + * @return {{ statement: string, isActivated: boolean }} + */ +const generateConstraint = ({ name, keys, keyType, isParentActivated, isCaseSensitive, comment, scriptFormat }) => { const keysAsStrings = keys.map(key => ({ ...key, name: `${getName(isCaseSensitive, key.name)}` })); const atLeastOneActive = keysAsStrings.some(key => key.isActivated); let finalStringOfKeys = foreignActiveKeysToString(isCaseSensitive, keysAsStrings); @@ -8,10 +21,12 @@ const generateConstraint = ({ name, keys, keyType, isParentActivated, isCaseSens finalStringOfKeys = foreignKeysToString(isCaseSensitive, keysAsStrings); } - const contraintName = name && name !== 'undefined' ? `CONSTRAINT ${getName(isCaseSensitive, name)} ` : ''; + const constraintName = name && name !== 'undefined' ? `CONSTRAINT ${getName(isCaseSensitive, name)} ` : ''; + + const commentStatement = comment ? ` COMMENT ${escapeString(scriptFormat, comment)}` : ''; return { - statement: contraintName + `${keyType} (${finalStringOfKeys})`, + statement: constraintName + `${keyType} (${finalStringOfKeys})` + commentStatement, isActivated: atLeastOneActive, }; }; diff --git a/forward_engineering/helpers/keyHelper.js b/forward_engineering/helpers/keyHelper.js index 2a2569eb..39c5f5cd 100644 --- a/forward_engineering/helpers/keyHelper.js +++ b/forward_engineering/helpers/keyHelper.js @@ -9,10 +9,6 @@ const { addQuotes } = require('./general'); module.exports = app => { const { clean } = app.require('@hackolade/ddl-fe-utils').general; - const mapProperties = (jsonSchema, iteratee) => { - return Object.entries(jsonSchema.properties).map(iteratee); - }; - const isUniqueKey = column => { return !(column.compositeUniqueKey || !column.unique); }; @@ -21,6 +17,16 @@ module.exports = app => { return !(column.compositeUniqueKey || column.compositePrimaryKey || !column.primaryKey); }; + const getKeyDefinition = (schema, optionsKey, flatNameKey) => { + const optionsList = schema?.[optionsKey]; + const options = Array.isArray(optionsList) ? _.first(optionsList) : optionsList; + + return { + constraintName: options?.constraintName || schema?.[flatNameKey], + indexComment: options?.indexComment, + }; + }; + const hydrateUniqueOptions = (options, columnName, isActivated, jsonSchema) => clean({ keyType: 'UNIQUE', @@ -105,36 +111,7 @@ module.exports = app => { return []; } - const primaryKeyConstraints = mapProperties(jsonSchema, ([name, schema]) => { - if (!isPrimaryKey(schema)) { - return; - } else if (_.isEmpty(schema.primaryKeyOptions)) { - return; - } - - return hydratePrimaryKeyOptions(_.first(schema.primaryKeyOptions), name, schema.isActivated, jsonSchema); - }).filter(Boolean); - - const uniqueKeyConstraints = _.flatten( - mapProperties(jsonSchema, ([name, schema]) => { - if (!isUniqueKey(schema)) { - return []; - } else if (_.isEmpty(schema.uniqueKeyOptions) || !Array.isArray(schema.uniqueKeyOptions)) { - return []; - } - - return schema.uniqueKeyOptions.map(uniqueKey => - hydrateUniqueOptions(uniqueKey, name, schema.isActivated, jsonSchema), - ); - }), - ).filter(Boolean); - - return [ - ...primaryKeyConstraints, - ...getCompositePrimaryKeys(jsonSchema), - ...uniqueKeyConstraints, - ...getCompositeUniqueKeys(jsonSchema), - ]; + return [...getCompositePrimaryKeys(jsonSchema), ...getCompositeUniqueKeys(jsonSchema)]; }; /** @@ -183,7 +160,7 @@ module.exports = app => { } return hydratePrimaryKeyOptions( - { constraintName: columnDefinition.primaryKeyConstraintName }, + getKeyDefinition(columnDefinition, 'primaryKeyOptions', 'primaryKeyConstraintName'), columnDefinition.name, columnDefinition.isActivated, jsonSchema, @@ -200,7 +177,7 @@ module.exports = app => { } return hydrateUniqueOptions( - { constraintName: columnDefinition.uniqueKeyConstraintName }, + getKeyDefinition(columnDefinition, 'uniqueKeyOptions', 'uniqueKeyConstraintName'), columnDefinition.name, columnDefinition.isActivated, jsonSchema, diff --git a/package-lock.json b/package-lock.json index 1cd8f93b..fc5d0e11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "Snowflake", - "version": "0.2.62", + "version": "0.2.64", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "Snowflake", - "version": "0.2.62", + "version": "0.2.64", "hasInstallScript": true, "dependencies": { "@hackolade/fetch": "1.3.0", @@ -30,7 +30,7 @@ "simple-git-hooks": "2.13.1" }, "engines": { - "hackolade": "7.7.10", + "hackolade": "8.13.6", "hackoladePlugin": "1.2.0" } }, diff --git a/package.json b/package.json index 3ea3b1ad..53b9f47f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "Snowflake", - "version": "0.2.63", + "version": "0.2.64", "author": "hackolade", "engines": { - "hackolade": "7.7.10", + "hackolade": "8.13.6", "hackoladePlugin": "1.2.0" }, "contributes": { @@ -97,4 +97,4 @@ "overrides": { "uuid": "$uuid" } -} \ No newline at end of file +} diff --git a/polyglot/adapter.json b/polyglot/adapter.json index 5458d1c3..35caa70f 100644 --- a/polyglot/adapter.json +++ b/polyglot/adapter.json @@ -63,7 +63,37 @@ "to": { "numChar": 8388608 } - } + }, + [ + "movePropertyByPath", + { + "from": "primaryKeyConstraintName", + "to": "primaryKeyOptions.constraintName" + } + ], + [ + "addMissingIdByPath", + { + "from": "primaryKeyOptions", + "path": "primaryKeyOptions.GUID" + } + ], + ["convertBlockPropertyToGroupProperty", "primaryKeyOptions"], + [ + "movePropertyByPath", + { + "from": "uniqueKeyConstraintName", + "to": "uniqueKeyOptions.constraintName" + } + ], + [ + "addMissingIdByPath", + { + "from": "uniqueKeyOptions", + "path": "uniqueKeyOptions.GUID" + } + ], + ["convertBlockPropertyToGroupProperty", "uniqueKeyOptions"] ] } } diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index 311da243..7e43724c 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -1778,6 +1778,14 @@ making sure that you maintain a proper JSON format. "propertyType": "primaryKeySetter", "abbr": "pk", "attributeList": [] + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" } ] }, @@ -1810,6 +1818,14 @@ making sure that you maintain a proper JSON format. "propertyTooltip": "", "propertyType": "checkbox", "setFieldPropertyBy": "compositeUniqueKey" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" } ] } diff --git a/properties_pane/field_level/fieldLevelConfig.json b/properties_pane/field_level/fieldLevelConfig.json index c7f00fae..68f3c8e8 100644 --- a/properties_pane/field_level/fieldLevelConfig.json +++ b/properties_pane/field_level/fieldLevelConfig.json @@ -326,9 +326,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -344,7 +346,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -457,13 +474,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "foreignCollection", "foreignField", @@ -898,9 +932,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -916,7 +952,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -1029,13 +1080,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "foreignCollection", "foreignField", @@ -1457,9 +1525,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -1475,7 +1545,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -1588,13 +1673,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "foreignCollection", "foreignField", @@ -2016,9 +2118,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -2034,7 +2138,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -2147,13 +2266,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "foreignCollection", "foreignField", @@ -2575,9 +2711,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -2593,7 +2731,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -2706,13 +2859,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "foreignCollection", "foreignField", @@ -3127,9 +3297,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -3145,7 +3317,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -3258,13 +3445,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "default", "sample", @@ -3607,9 +3811,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -3625,7 +3831,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -3738,13 +3959,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Column Tags", @@ -4072,9 +4310,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -4090,7 +4330,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -4203,13 +4458,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "pattern", "default", @@ -4550,9 +4822,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -4568,7 +4842,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -4681,13 +4970,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "pattern", "default", @@ -5036,9 +5342,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -5054,7 +5362,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -5167,13 +5490,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "pattern", "default", @@ -5522,9 +5862,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -5540,7 +5882,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -5653,13 +6010,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "pattern", "default", @@ -6008,9 +6382,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -6026,7 +6402,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -6139,13 +6530,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "pattern", "default", @@ -6576,9 +6984,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -6594,7 +7004,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -6686,13 +7111,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "minProperties", "maxProperties", @@ -7034,9 +7476,11 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Primary key constraint name", - "propertyKeyword": "primaryKeyConstraintName", - "propertyType": "text", + "propertyName": "Primary key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "primaryKeyOptions", + "propertyTooltip": "Primary key options", "dependency": { "type": "and", "values": [ @@ -7052,7 +7496,22 @@ making sure that you maintain a proper JSON format. } } ] - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, { "propertyName": "Not null", @@ -7145,13 +7604,30 @@ making sure that you maintain a proper JSON format. ] }, { - "propertyName": "Unique key constraint name", - "propertyKeyword": "uniqueKeyConstraintName", - "propertyType": "text", + "propertyName": "Unique key options", + "propertyType": "group", + "groupItemLimit": 1, + "propertyKeyword": "uniqueKeyOptions", + "propertyTooltip": "Unique key options", "dependency": { "key": "unique", "value": true - } + }, + "structure": [ + { + "propertyName": "Constraint name", + "propertyKeyword": "constraintName", + "propertyType": "text" + }, + { + "propertyName": "Comment", + "propertyKeyword": "indexComment", + "propertyTooltip": "comment", + "addTimestampButton": false, + "propertyType": "details", + "template": "textarea" + } + ] }, "minProperties", "maxProperties",