@dbcube/cli 5.2.1 → 5.2.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbcube/cli",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dbcube": "node src/index.js"
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@dbcube/schema-builder": "^5.2.
|
|
31
|
+
"@dbcube/schema-builder": "^5.2.2",
|
|
32
32
|
"@inquirer/prompts": "^8.5.2",
|
|
33
33
|
"alwait": "^1.0.0",
|
|
34
34
|
"chalk": "4.1.2",
|
|
35
|
-
"dbcube": "^5.2.
|
|
35
|
+
"dbcube": "^5.2.2",
|
|
36
36
|
"dotenv": "^17.4.2",
|
|
37
37
|
"fs-extra": "^11.3.5",
|
|
38
38
|
"glob": "^13.0.6",
|
package/src/commands/run/pull.js
CHANGED
|
@@ -170,7 +170,11 @@ function renderCube(dbName, tableName, table) {
|
|
|
170
170
|
out += `@meta({\n name: "${tableName}";\n description: "Imported from existing database by dbcube pull";\n});\n\n`;
|
|
171
171
|
out += `@columns({\n`;
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
// uuid la genera y gestiona DBCube automáticamente: declararla en un
|
|
174
|
+
// .cube es un error de validación, así que se excluye del cube generado
|
|
175
|
+
const columns = table.columns.filter(c => c.name !== 'uuid' && c.name !== '_id');
|
|
176
|
+
|
|
177
|
+
for (const col of columns) {
|
|
174
178
|
const cubeType = SQL_TYPE_MAP[col.dataType] || 'varchar';
|
|
175
179
|
out += ` ${col.name}: {\n`;
|
|
176
180
|
out += ` type: "${cubeType === 'enum' && !col.enumValues ? 'varchar' : cubeType}";\n`;
|
|
@@ -32,15 +32,25 @@ async function main() {
|
|
|
32
32
|
const targetNames = targetFiles.map(f => path.basename(f));
|
|
33
33
|
const configuredDatabases = await ConfigFileUtils.getConfiguredDatabases();
|
|
34
34
|
|
|
35
|
+
let totalErrors = 0;
|
|
35
36
|
for (const config of configuredDatabases) {
|
|
36
37
|
const schema = new Schema(config.name);
|
|
37
38
|
try {
|
|
38
|
-
await schema.executeAlters(targetNames, { dryRun });
|
|
39
|
+
const result = await schema.executeAlters(targetNames, { dryRun });
|
|
40
|
+
totalErrors += result?.errors ?? 0;
|
|
39
41
|
} catch (e) {
|
|
40
42
|
if (!String(e.message).includes('no .alter.cube files')) throw e;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
// Una migración que falló NO puede quedar registrada como aplicada:
|
|
47
|
+
// jamás se reintentaría y la DB quedaría desincronizada del historial
|
|
48
|
+
if (totalErrors > 0) {
|
|
49
|
+
console.error(`\n❌ ${totalErrors} error(s) applying migrations — batch NOT recorded.`);
|
|
50
|
+
console.error(' Fix the .alter.cube files and run table:alter again.\n');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
// Record history (skip on dry-run)
|
|
45
55
|
if (!dryRun) {
|
|
46
56
|
const batch = history.lastBatch + 1;
|