cormo
Advanced tools
Comparing version 0.16.2 to 0.16.3
@@ -151,2 +151,3 @@ /// <reference types="node" /> | ||
verbose?: boolean; | ||
apply_description_change?: boolean; | ||
}): Promise<void>; | ||
@@ -153,0 +154,0 @@ isApplyingSchemasNecessary(): Promise<boolean>; |
@@ -163,4 +163,25 @@ "use strict"; | ||
} | ||
let type_changed = false; | ||
if (column !== 'id') { | ||
if (property.required && !current_column.required) { | ||
type_changed = true; | ||
} | ||
else if (!property.required && current_column.required) { | ||
type_changed = true; | ||
} | ||
} | ||
const expected_type = this._adapter.getAdapterTypeString(property); | ||
const real_type = current_column.adapter_type_string; | ||
if (expected_type !== real_type) { | ||
type_changed = true; | ||
} | ||
if (((_a = current_column.description) !== null && _a !== void 0 ? _a : '') !== ((_b = property.description) !== null && _b !== void 0 ? _b : '')) { | ||
await this._adapter.updateColumnDescription(model, property, options.verbose); | ||
if (!type_changed) { | ||
if (options.apply_description_change) { | ||
await this._adapter.updateColumnDescription(model, property, options.verbose); | ||
} | ||
} | ||
else { | ||
// do not update description to prevent unexpected type change | ||
} | ||
} | ||
@@ -179,6 +200,8 @@ } | ||
else if (current_table !== 'NO SCHEMA' && ((_c = current_table.description) !== null && _c !== void 0 ? _c : '') !== ((_d = modelClass.description) !== null && _d !== void 0 ? _d : '')) { | ||
if (options.verbose) { | ||
console.log(`Changing table ${modelClass.table_name}'s description to '${modelClass.description}'`); | ||
if (options.apply_description_change) { | ||
if (options.verbose) { | ||
console.log(`Changing table ${modelClass.table_name}'s description to '${modelClass.description}'`); | ||
} | ||
await this._adapter.updateTableDescription(model, options.verbose); | ||
} | ||
await this._adapter.updateTableDescription(model, options.verbose); | ||
} | ||
@@ -268,7 +291,10 @@ } | ||
} | ||
let type_changed = false; | ||
if (column !== 'id') { | ||
if (property.required && !current_column.required) { | ||
type_changed = true; | ||
changes.push({ message: `Change ${modelClass.table_name}.${property._dbname_us} to required`, ignorable: true }); | ||
} | ||
else if (!property.required && current_column.required) { | ||
type_changed = true; | ||
changes.push({ message: `Change ${modelClass.table_name}.${column} to optional`, ignorable: true }); | ||
@@ -280,10 +306,16 @@ } | ||
if (expected_type !== real_type) { | ||
type_changed = true; | ||
changes.push({ message: `Type different ${modelClass.table_name}.${column}: expected=${expected_type}, real=${real_type}`, ignorable: true }); | ||
} | ||
if (((_a = current_column.description) !== null && _a !== void 0 ? _a : '') !== ((_b = property.description) !== null && _b !== void 0 ? _b : '')) { | ||
changes.push({ message: `Change ${modelClass.table_name}.${column}'s description to '${property.description}'` }); | ||
const query = this._adapter.getUpdateColumnDescriptionQuery(model, property); | ||
if (query) { | ||
changes.push({ message: ` (${query})`, is_query: true, ignorable: true }); | ||
if (!type_changed) { | ||
changes.push({ message: `Change ${modelClass.table_name}.${column}'s description to '${property.description}'`, ignorable: true }); | ||
const query = this._adapter.getUpdateColumnDescriptionQuery(model, property); | ||
if (query) { | ||
changes.push({ message: ` (${query})`, is_query: true, ignorable: true }); | ||
} | ||
} | ||
else { | ||
changes.push({ message: `(Skip) Change ${modelClass.table_name}.${column}'s description to '${property.description}'`, ignorable: true }); | ||
} | ||
} | ||
@@ -308,3 +340,3 @@ } | ||
else if (current_table !== 'NO SCHEMA' && ((_c = current_table.description) !== null && _c !== void 0 ? _c : '') !== ((_d = modelClass.description) !== null && _d !== void 0 ? _d : '')) { | ||
changes.push({ message: `Change table ${modelClass.table_name}'s description to '${modelClass.description}'` }); | ||
changes.push({ message: `Change table ${modelClass.table_name}'s description to '${modelClass.description}'`, ignorable: true }); | ||
const query = this._adapter.getUpdateTableDescriptionQuery(model); | ||
@@ -311,0 +343,0 @@ if (query) { |
{ | ||
"name": "cormo", | ||
"description": "ORM framework for Node.js", | ||
"version": "0.16.2", | ||
"version": "0.16.3", | ||
"keywords": [ | ||
@@ -71,3 +71,3 @@ "orm", | ||
}, | ||
"gitHead": "fc004aa446a4a6bd8416bd61b29206b2c7262063" | ||
"gitHead": "1931ecdf33f0f54c914b060b1f7da7a78fd5f6be" | ||
} |
343772
9392