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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions forward_engineering/configs/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,6 @@ module.exports = {
alterTableAddConstraint: 'ALTER TABLE IF EXISTS ${tableName} ADD ${statement};',
alterTableDropNamedConstraint: 'ALTER TABLE IF EXISTS ${tableName} DROP CONSTRAINT ${constraintName};',
alterTableDropStatement: 'ALTER TABLE IF EXISTS ${tableName} DROP ${statement};',

columnComment: 'COMMENT ON COLUMN ${fullName} IS ${comment}',
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getAddCollectionScript =
const { schemaName, databaseName } = getBaseAndContainerNames(collection, getName);
const jsonSchema = {
...collection,
...(_.omit(collection?.role, 'properties') || {}),
..._.omit(collection?.role, 'properties'),
};
const columnDefinitions = _.toPairs(jsonSchema.properties).map(([name, column]) =>
createColumnDefinitionBySchema({
Expand Down Expand Up @@ -47,7 +47,7 @@ const getAddCollectionScript =
const getDeleteCollectionScript = collection => {
const jsonData = {
...collection,
...(_.omit(collection?.role, 'properties') || {}),
..._.omit(collection?.role, 'properties'),
};
const { schemaName, databaseName, tableName } = getNames(jsonData, getName, getEntityName);
const fullName = getFullName(databaseName, getFullName(schemaName, tableName));
Expand All @@ -66,7 +66,7 @@ const getAddColumnScript =
collection => {
const collectionSchema = {
...collection,
...(_.omit(collection?.role, 'properties') || {}),
..._.omit(collection?.role, 'properties'),
};
const { schemaName, databaseName, tableName } = getNames(collectionSchema, getName, getEntityName);
const fullName = getFullName(databaseName, getFullName(schemaName, tableName));
Expand All @@ -92,7 +92,7 @@ const getAddColumnScript =
const getDeleteColumnScript = collection => {
const collectionSchema = {
...collection,
...(_.omit(collection?.role, 'properties') || {}),
..._.omit(collection?.role, 'properties'),
};
const { schemaName, databaseName, tableName } = getNames(collectionSchema, getName, getEntityName);
const fullName = getFullName(databaseName, getFullName(schemaName, tableName));
Expand Down Expand Up @@ -165,9 +165,9 @@ const getModifyColumnScript =

// new or modified comment
if (oldComment !== comment) {
return assignTemplates(templates.alterTable, {
name: fullName,
action: `MODIFY COLUMN ${columnName} COMMENT = ${escapeString(scriptFormat, comment)}`,
return assignTemplates(templates.columnComment, {
fullName: `${fullName}.${columnName}`,
comment: escapeString(scriptFormat, comment),
});
}
})
Expand Down