rake-db 2.10.3 → 2.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1064,7 +1064,9 @@ const astToQueries = (ast, snakeCase, language) => {
|
|
|
1064
1064
|
} else if (item.type === "change") {
|
|
1065
1065
|
const { from, to } = item;
|
|
1066
1066
|
const name = getChangeColumnName(item, key, snakeCase);
|
|
1067
|
+
let changeType = false;
|
|
1067
1068
|
if (to.type && (from.type !== to.type || from.collate !== to.collate)) {
|
|
1069
|
+
changeType = true;
|
|
1068
1070
|
const type = !to.column || to.column.data.isOfCustomType ? `"${to.type}"` : to.type;
|
|
1069
1071
|
alterTable.push(
|
|
1070
1072
|
`ALTER COLUMN "${name}" TYPE ${type}${to.collate ? ` COLLATE ${quoteNameFromString(to.collate)}` : ""}${item.using ? ` USING ${item.using.toSQL({ values })}` : ""}`
|
|
@@ -1076,7 +1078,10 @@ const astToQueries = (ast, snakeCase, language) => {
|
|
|
1076
1078
|
);
|
|
1077
1079
|
}
|
|
1078
1080
|
if (from.default !== to.default) {
|
|
1079
|
-
const value = typeof to.default === "object" && to.default && isRawSQL(to.default) ? to.default.toSQL({ values }) : quote(to.default);
|
|
1081
|
+
const value = to.default === void 0 ? void 0 : typeof to.default === "object" && to.default && isRawSQL(to.default) ? to.default.toSQL({ values }) : quote(to.default);
|
|
1082
|
+
if (changeType && value !== void 0) {
|
|
1083
|
+
alterTable.push(`ALTER COLUMN "${name}" DROP DEFAULT`);
|
|
1084
|
+
}
|
|
1080
1085
|
const expr = value === void 0 ? "DROP DEFAULT" : `SET DEFAULT ${value}`;
|
|
1081
1086
|
alterTable.push(`ALTER COLUMN "${name}" ${expr}`);
|
|
1082
1087
|
}
|