rake-db 2.10.32 → 2.10.34
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 +36 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -24,6 +24,18 @@ var __spreadValues$6 = (a, b) => {
|
|
|
24
24
|
return a;
|
|
25
25
|
};
|
|
26
26
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
27
|
+
var __objRest$2 = (source, exclude) => {
|
|
28
|
+
var target = {};
|
|
29
|
+
for (var prop in source)
|
|
30
|
+
if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
if (source != null && __getOwnPropSymbols$6)
|
|
33
|
+
for (var prop of __getOwnPropSymbols$6(source)) {
|
|
34
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
|
|
35
|
+
target[prop] = source[prop];
|
|
36
|
+
}
|
|
37
|
+
return target;
|
|
38
|
+
};
|
|
27
39
|
const migrationConfigDefaults = {
|
|
28
40
|
migrationsPath: path.join("src", "db", "migrations"),
|
|
29
41
|
migrationsTable: "schemaMigrations",
|
|
@@ -209,19 +221,29 @@ const getTextAfterTo = (input) => {
|
|
|
209
221
|
const getTextAfterFrom = (input) => {
|
|
210
222
|
return getTextAfterRegExp(input, /(From|-from|_from)[A-Z-_]/, 4);
|
|
211
223
|
};
|
|
212
|
-
const getMigrations = async (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
+
const getMigrations = async (_a, up) => {
|
|
225
|
+
var _b = _a, {
|
|
226
|
+
migrations
|
|
227
|
+
} = _b, config = __objRest$2(_b, [
|
|
228
|
+
"migrations"
|
|
229
|
+
]);
|
|
230
|
+
return migrations ? getMigrationsFromConfig(__spreadProps$5(__spreadValues$6({}, config), { migrations }), up) : getMigrationsFromFiles(config, up);
|
|
231
|
+
};
|
|
232
|
+
function getMigrationsFromConfig(config, up) {
|
|
233
|
+
const result = [];
|
|
234
|
+
const { migrations, basePath } = config;
|
|
235
|
+
for (const key in migrations) {
|
|
236
|
+
result.push({
|
|
237
|
+
path: path.resolve(basePath, key),
|
|
238
|
+
version: getVersion(path.basename(key)),
|
|
239
|
+
change: migrations[key]
|
|
240
|
+
});
|
|
224
241
|
}
|
|
242
|
+
if (!up)
|
|
243
|
+
result.reverse();
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
async function getMigrationsFromFiles(config, up) {
|
|
225
247
|
const { migrationsPath, import: imp } = config;
|
|
226
248
|
let files;
|
|
227
249
|
try {
|
|
@@ -248,12 +270,12 @@ const getMigrations = async (config, up) => {
|
|
|
248
270
|
}
|
|
249
271
|
};
|
|
250
272
|
});
|
|
251
|
-
}
|
|
273
|
+
}
|
|
252
274
|
function checkExt(filePath) {
|
|
253
275
|
const ext = path.extname(filePath);
|
|
254
276
|
if (ext !== ".ts" && ext !== ".js" && ext !== ".mjs") {
|
|
255
277
|
throw new Error(
|
|
256
|
-
`Only .ts and .
|
|
278
|
+
`Only .ts, .js, and .mjs files are supported for migration, received: ${path}`
|
|
257
279
|
);
|
|
258
280
|
}
|
|
259
281
|
}
|