@db-bridge/core 1.1.5 → 1.1.7
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/cli/index.js +18 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -84,7 +84,7 @@ function applyDefaults(config) {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
var MIGRATION_PATTERN = /^(\d{14})_(.+)\.(ts|js|mjs)$/;
|
|
87
|
+
var MIGRATION_PATTERN = /^(?:([_a-z]+)_)?(\d{14})_(.+)\.(ts|js|mjs)$/;
|
|
88
88
|
var MigrationLoader = class {
|
|
89
89
|
directory;
|
|
90
90
|
extensions;
|
|
@@ -111,12 +111,13 @@ var MigrationLoader = class {
|
|
|
111
111
|
if (!match) {
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
|
-
const [, timestamp, description] = match;
|
|
114
|
+
const [, prefix, timestamp, description] = match;
|
|
115
115
|
files.push({
|
|
116
116
|
name: basename(entry.name, ext),
|
|
117
117
|
path: join(this.directory, entry.name),
|
|
118
118
|
timestamp,
|
|
119
|
-
description: description.replaceAll("_", " ")
|
|
119
|
+
description: description.replaceAll("_", " "),
|
|
120
|
+
prefix
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
files.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
@@ -193,8 +194,10 @@ var MigrationLoader = class {
|
|
|
193
194
|
}
|
|
194
195
|
/**
|
|
195
196
|
* Generate a new migration filename
|
|
197
|
+
* @param description - Migration description
|
|
198
|
+
* @param prefix - Optional prefix (e.g., 'auth' -> auth_20250119_xxx.ts)
|
|
196
199
|
*/
|
|
197
|
-
static generateFilename(description) {
|
|
200
|
+
static generateFilename(description, prefix) {
|
|
198
201
|
const now = /* @__PURE__ */ new Date();
|
|
199
202
|
const timestamp = [
|
|
200
203
|
now.getFullYear(),
|
|
@@ -205,7 +208,8 @@ var MigrationLoader = class {
|
|
|
205
208
|
String(now.getSeconds()).padStart(2, "0")
|
|
206
209
|
].join("");
|
|
207
210
|
const sanitizedDescription = description.toLowerCase().replaceAll(/[^\da-z]+/g, "_").replaceAll(/^_+|_+$/g, "");
|
|
208
|
-
|
|
211
|
+
const sanitizedPrefix = prefix ? prefix.toLowerCase().replaceAll(/[^\da-z]+/g, "_").replaceAll(/^_+|_+$/g, "") : null;
|
|
212
|
+
return sanitizedPrefix ? `${sanitizedPrefix}_${timestamp}_${sanitizedDescription}.ts` : `${timestamp}_${sanitizedDescription}.ts`;
|
|
209
213
|
}
|
|
210
214
|
/**
|
|
211
215
|
* Get migration template content
|
|
@@ -2460,7 +2464,8 @@ async function makeCommand(name) {
|
|
|
2460
2464
|
await mkdir(directory, { recursive: true });
|
|
2461
2465
|
console.log(`Created migrations directory: ${directory}`);
|
|
2462
2466
|
}
|
|
2463
|
-
const
|
|
2467
|
+
const prefix = config.migrations?.prefix;
|
|
2468
|
+
const filename = MigrationLoader.generateFilename(name, prefix);
|
|
2464
2469
|
const filepath = resolve(directory, filename);
|
|
2465
2470
|
const migrationName = filename.replace(/\.(ts|js|mjs)$/, "");
|
|
2466
2471
|
const content = MigrationLoader.getMigrationTemplate(migrationName);
|
|
@@ -2511,10 +2516,13 @@ var SeederLoader = class {
|
|
|
2511
2516
|
}
|
|
2512
2517
|
/**
|
|
2513
2518
|
* Generate a new seeder filename
|
|
2519
|
+
* @param name - Seeder name
|
|
2520
|
+
* @param prefix - Optional prefix (e.g., 'auth' -> auth_users_seeder.ts)
|
|
2514
2521
|
*/
|
|
2515
|
-
static generateFilename(name) {
|
|
2522
|
+
static generateFilename(name, prefix) {
|
|
2516
2523
|
const snakeName = name.replaceAll(/([a-z])([A-Z])/g, "$1_$2").replaceAll(/[\s-]+/g, "_").toLowerCase();
|
|
2517
|
-
|
|
2524
|
+
const sanitizedPrefix = prefix ? prefix.toLowerCase().replaceAll(/[^\da-z]+/g, "_").replaceAll(/^_+|_+$/g, "") : null;
|
|
2525
|
+
return sanitizedPrefix ? `${sanitizedPrefix}_${snakeName}_seeder.ts` : `${snakeName}_seeder.ts`;
|
|
2518
2526
|
}
|
|
2519
2527
|
/**
|
|
2520
2528
|
* Get seeder template
|
|
@@ -2550,7 +2558,8 @@ async function makeSeederCommand(name) {
|
|
|
2550
2558
|
await mkdir(directory, { recursive: true });
|
|
2551
2559
|
console.log(`Created seeds directory: ${directory}`);
|
|
2552
2560
|
}
|
|
2553
|
-
const
|
|
2561
|
+
const prefix = config.seeds?.prefix;
|
|
2562
|
+
const filename = SeederLoader.generateFilename(name, prefix);
|
|
2554
2563
|
const filepath = resolve(directory, filename);
|
|
2555
2564
|
const seederName = filename.replace(/\.(ts|js|mjs)$/, "");
|
|
2556
2565
|
const content = SeederLoader.getSeederTemplate(seederName);
|