rake-db 2.22.8 → 2.22.9
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 +29 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1212,7 +1212,7 @@ const handleTableItemChange = (key, item, ast, alterTable, renameItems, values,
|
|
|
1212
1212
|
for (let i = 0; i < indexesLen; i++) {
|
|
1213
1213
|
const fromIndex = (_v = from.indexes) == null ? void 0 : _v[i];
|
|
1214
1214
|
const toIndex = (_w = to.indexes) == null ? void 0 : _w[i];
|
|
1215
|
-
if ((fromIndex || toIndex) && (!fromIndex || !toIndex ||
|
|
1215
|
+
if ((fromIndex || toIndex) && (!fromIndex || !toIndex || !orchidCore.deepCompare(fromIndex, toIndex))) {
|
|
1216
1216
|
if (fromIndex) {
|
|
1217
1217
|
dropIndexes.push(__spreadProps$5(__spreadValues$7({}, fromIndex), {
|
|
1218
1218
|
columns: [
|
|
@@ -4984,11 +4984,17 @@ const astEncoders = {
|
|
|
4984
4984
|
ast.shape.createdAt,
|
|
4985
4985
|
ast.shape.updatedAt
|
|
4986
4986
|
);
|
|
4987
|
+
const toCodeCtx = {
|
|
4988
|
+
t: "t",
|
|
4989
|
+
table: ast.name,
|
|
4990
|
+
migration: true,
|
|
4991
|
+
snakeCase: config.snakeCase
|
|
4992
|
+
};
|
|
4987
4993
|
for (const key in ast.shape) {
|
|
4988
4994
|
if (timestamps.hasAnyTimestamps && (key === "createdAt" || key === "updatedAt"))
|
|
4989
4995
|
continue;
|
|
4990
4996
|
const line = [`${orchidCore.quoteObjectKey(key)}: `];
|
|
4991
|
-
const columnCode =
|
|
4997
|
+
const columnCode = ast.shape[key].toCode(toCodeCtx, key);
|
|
4992
4998
|
for (const part of columnCode) {
|
|
4993
4999
|
orchidCore.addCode(line, part);
|
|
4994
5000
|
}
|
|
@@ -5038,6 +5044,12 @@ const astEncoders = {
|
|
|
5038
5044
|
);
|
|
5039
5045
|
}
|
|
5040
5046
|
);
|
|
5047
|
+
const toCodeCtx = {
|
|
5048
|
+
t: "t",
|
|
5049
|
+
table: ast.name,
|
|
5050
|
+
migration: true,
|
|
5051
|
+
snakeCase: config.snakeCase
|
|
5052
|
+
};
|
|
5041
5053
|
for (const key in ast.shape) {
|
|
5042
5054
|
const changes = orchidCore.toArray(ast.shape[key]);
|
|
5043
5055
|
for (const change of changes) {
|
|
@@ -5050,7 +5062,7 @@ const astEncoders = {
|
|
|
5050
5062
|
(_a = change.item.data.name) != null ? _a : key
|
|
5051
5063
|
)})` : `${orchidCore.quoteObjectKey(key)}: t.${change.type}(`
|
|
5052
5064
|
];
|
|
5053
|
-
const columnCode =
|
|
5065
|
+
const columnCode = change.item.toCode(toCodeCtx, key);
|
|
5054
5066
|
for (let i = 0; i < columnCode.length; i++) {
|
|
5055
5067
|
let part = columnCode[i];
|
|
5056
5068
|
if (recreate && !i)
|
|
@@ -5065,16 +5077,20 @@ const astEncoders = {
|
|
|
5065
5077
|
const line = [
|
|
5066
5078
|
`${orchidCore.quoteObjectKey(key)}: t${change.name ? `.name(${orchidCore.singleQuote(change.name)})` : ""}.change(`
|
|
5067
5079
|
];
|
|
5068
|
-
const fromCode =
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5080
|
+
const fromCode = change.from.column.toCode(
|
|
5081
|
+
{
|
|
5082
|
+
t: "t",
|
|
5083
|
+
table: ast.name,
|
|
5084
|
+
migration: true,
|
|
5085
|
+
snakeCase: config.snakeCase
|
|
5086
|
+
},
|
|
5087
|
+
key
|
|
5072
5088
|
);
|
|
5073
5089
|
for (const part of fromCode) {
|
|
5074
5090
|
orchidCore.addCode(line, part);
|
|
5075
5091
|
}
|
|
5076
5092
|
orchidCore.addCode(line, ", ");
|
|
5077
|
-
const toCode =
|
|
5093
|
+
const toCode = change.to.column.toCode(toCodeCtx, key);
|
|
5078
5094
|
for (const part of toCode) {
|
|
5079
5095
|
orchidCore.addCode(line, part);
|
|
5080
5096
|
}
|
|
@@ -5198,9 +5214,13 @@ const astEncoders = {
|
|
|
5198
5214
|
)}, [${ast.fromValues.map(orchidCore.singleQuote).join(", ")}], [${ast.toValues.map(orchidCore.singleQuote).join(", ")}]);`;
|
|
5199
5215
|
},
|
|
5200
5216
|
domain(ast) {
|
|
5217
|
+
var _a;
|
|
5201
5218
|
return `await db.${ast.action}Domain(${quoteSchemaTable(
|
|
5202
5219
|
ast
|
|
5203
|
-
)}, (t) => ${ast.baseType.toCode(
|
|
5220
|
+
)}, (t) => ${ast.baseType.toCode(
|
|
5221
|
+
{ t: "t", table: ast.name },
|
|
5222
|
+
(_a = ast.baseType.data.name) != null ? _a : ""
|
|
5223
|
+
)});`;
|
|
5204
5224
|
},
|
|
5205
5225
|
collation(ast) {
|
|
5206
5226
|
const params = [];
|