@@ -20,6 +20,7 @@ const {
2020 getColumnsList,
2121 prepareNameForScriptFormat,
2222} = require ( '../utils/general' ) ;
23+ const { getAnnotationsString } = require ( '../utils/getAnnotationsString' ) ;
2324const { assignTemplates } = require ( '../utils/assignTemplates' ) ;
2425const { decorateType } = require ( './ddlHelpers/columnDefinitionHelpers/decorateType' ) ;
2526const { getNotNullConstraints } = require ( '../alterScript/alterScriptHelpers/columnHelpers/nonNullConstraintHelper' ) ;
@@ -65,6 +66,7 @@ module.exports = (baseProvider, options, app) => {
6566 commentIfDeactivated,
6667 prepareName,
6768 assignTemplates,
69+ wrapComment,
6870 } ) ;
6971
7072 const { getUserDefinedType, isNotPlainType } = require ( './ddlHelpers/udtHelper' ) ( {
@@ -206,6 +208,7 @@ module.exports = (baseProvider, options, app) => {
206208 subtype : jsonSchema . subtype ,
207209 defaultOnNull : jsonSchema . defaultOnNull ,
208210 generatedDefaultValue : jsonSchema . generatedDefaultValue ,
211+ columnAnnotations : jsonSchema . columnAnnotations ,
209212 } ;
210213 } ,
211214
@@ -220,6 +223,8 @@ module.exports = (baseProvider, options, app) => {
220223
221224 convertColumnDefinition ( columnDefinition , template = templates . columnDefinition ) {
222225 const type = replaceTypeByVersion ( columnDefinition . type , columnDefinition . dbVersion ) ;
226+ const annotations = getAnnotationsString ( prepareName ) ( columnDefinition . columnAnnotations ) ;
227+ const finalAnnotationsClause = annotations ? ' ' + annotations : '' ;
223228
224229 return commentIfDeactivated (
225230 assignTemplates ( template , {
@@ -228,6 +233,7 @@ module.exports = (baseProvider, options, app) => {
228233 default : getColumnDefault ( columnDefinition ) ,
229234 encrypt : getColumnEncrypt ( columnDefinition ) ,
230235 constraints : getColumnConstraints ( columnDefinition ) ,
236+ annotations : finalAnnotationsClause ,
231237 } ) ,
232238 {
233239 isActivated : columnDefinition . isActivated ,
@@ -375,6 +381,7 @@ module.exports = (baseProvider, options, app) => {
375381 'description' ,
376382 'ifNotExist' ,
377383 'tableProperties' ,
384+ 'tableAnnotations' ,
378385 ) ,
379386 synonyms :
380387 tableData ?. schemaData ?. synonyms ?. filter ( synonym => synonym . synonymEntityId === jsonSchema . GUID ) ||
@@ -407,6 +414,7 @@ module.exports = (baseProvider, options, app) => {
407414 tableProperties,
408415 synonyms,
409416 notNullConstraints,
417+ tableAnnotations,
410418 } ,
411419 isActivated ,
412420 ) {
@@ -471,6 +479,7 @@ module.exports = (baseProvider, options, app) => {
471479 partitioning,
472480 selectStatement,
473481 tableProperties,
482+ tableAnnotations,
474483 } ) ,
475484 } ) ;
476485 if ( usingTryCatchWrapper ) {
@@ -485,7 +494,7 @@ module.exports = (baseProvider, options, app) => {
485494 } ,
486495
487496 hydrateIndex ( indexData , tableData , schemaData ) {
488- return { ...indexData , schemaName : schemaData . schemaName } ;
497+ return { ...indexData , schemaName : schemaData . schemaName , indexAnnotations : indexData . indexAnnotations } ;
489498 } ,
490499
491500 createIndex ( tableName , index , dbData , isParentActivated = true ) {
@@ -501,6 +510,9 @@ module.exports = (baseProvider, options, app) => {
501510 const dbVersion = options . dbVersion || '' ;
502511 const usingTryCatchWrapper = shouldUseTryCatchIfNotExistsWrapper ( dbVersion ) ;
503512
513+ const annotations = getAnnotationsString ( prepareName ) ( index . indexAnnotations ) ;
514+ const finalAnnotationsClause = annotations ? ' ' + annotations : '' ;
515+
504516 const shouldInsertIfNotExistsStatement = index . ifNotExist && ! usingTryCatchWrapper ;
505517
506518 let statement = assignTemplates ( templates . createIndex , {
@@ -510,6 +522,7 @@ module.exports = (baseProvider, options, app) => {
510522 keys,
511523 options : indexOptions ,
512524 tableName : getNamePrefixedWithSchemaName ( tableName , index . schemaName ) ,
525+ annotations : finalAnnotationsClause ,
513526 } ) ;
514527
515528 if ( index . ifNotExist && usingTryCatchWrapper ) {
@@ -587,6 +600,7 @@ module.exports = (baseProvider, options, app) => {
587600 dbVersion : _ . get ( viewData , 'schemaData.dbVersion' ) ,
588601 } ,
589602 whereClause : detailsTab . whereClause ,
603+ viewAnnotations : detailsTab . viewAnnotations ,
590604 } ;
591605 } ,
592606
@@ -650,6 +664,8 @@ module.exports = (baseProvider, options, app) => {
650664 const dbVersion = _ . get ( viewData , 'modelInfo.dbVersion' , '' ) ;
651665 const usingTryCatchWrapper = shouldUseTryCatchIfNotExistsWrapper ( dbVersion ) ;
652666
667+ const annotations = getAnnotationsString ( prepareName ) ( viewData . viewAnnotations ) ;
668+
653669 let createViewDdl = assignTemplates ( templates . createView , {
654670 name : viewName ,
655671 ifNotExists : ! usingTryCatchWrapper && viewData . ifNotExist ? ' IF NOT EXISTS' : '' ,
@@ -660,6 +676,7 @@ module.exports = (baseProvider, options, app) => {
660676 viewProperties : viewData . viewProperties ? ' \n' + tab ( viewData . viewProperties ) : '' ,
661677 sharing : viewData . sharing && ! viewData . materialized ? ` SHARING=${ viewData . sharing } ` : '' ,
662678 selectStatement,
679+ annotations : annotations ? `\n\t${ annotations } ` : '' ,
663680 } ) ;
664681 if ( usingTryCatchWrapper ) {
665682 createViewDdl = wrapIfNotExists ( createViewDdl , viewData . ifNotExist ) ;
0 commit comments