relq 1.0.103 → 1.0.104
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.
|
@@ -415,6 +415,25 @@ function generateColumnModification(tableName, columnName, changes) {
|
|
|
415
415
|
}
|
|
416
416
|
break;
|
|
417
417
|
}
|
|
418
|
+
case 'precision':
|
|
419
|
+
case 'scale': {
|
|
420
|
+
if (change.field === 'precision') {
|
|
421
|
+
const newPrec = change.to;
|
|
422
|
+
const scaleChange = changes.find(c => c.field === 'scale');
|
|
423
|
+
const newScale = scaleChange ? scaleChange.to : undefined;
|
|
424
|
+
const oldPrec = change.from;
|
|
425
|
+
const oldScale = scaleChange ? scaleChange.from : undefined;
|
|
426
|
+
const newFullType = newPrec != null
|
|
427
|
+
? (newScale != null ? `NUMERIC(${newPrec}, ${newScale})` : `NUMERIC(${newPrec})`)
|
|
428
|
+
: 'NUMERIC';
|
|
429
|
+
const oldFullType = oldPrec != null
|
|
430
|
+
? (oldScale != null ? `NUMERIC(${oldPrec}, ${oldScale})` : `NUMERIC(${oldPrec})`)
|
|
431
|
+
: 'NUMERIC';
|
|
432
|
+
upSQL.push(`ALTER TABLE "${tableName}" ALTER COLUMN "${columnName}" TYPE ${newFullType};`);
|
|
433
|
+
downSQL.push(`ALTER TABLE "${tableName}" ALTER COLUMN "${columnName}" TYPE ${oldFullType};`);
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
418
437
|
}
|
|
419
438
|
}
|
|
420
439
|
return { upSQL, downSQL };
|
|
@@ -1072,6 +1072,21 @@ function compareColumnProperties(oldCol, newCol) {
|
|
|
1072
1072
|
if (oldCol.defaultValue !== newCol.defaultValue) {
|
|
1073
1073
|
changes.push({ field: 'default', from: oldCol.defaultValue, to: newCol.defaultValue });
|
|
1074
1074
|
}
|
|
1075
|
+
const oldLength = oldCol.typeParams?.length;
|
|
1076
|
+
const newLength = newCol.typeParams?.length;
|
|
1077
|
+
if (oldLength !== newLength) {
|
|
1078
|
+
changes.push({ field: 'length', from: oldLength, to: newLength });
|
|
1079
|
+
}
|
|
1080
|
+
const oldPrecision = oldCol.typeParams?.precision;
|
|
1081
|
+
const newPrecision = newCol.typeParams?.precision;
|
|
1082
|
+
if (oldPrecision !== newPrecision) {
|
|
1083
|
+
changes.push({ field: 'precision', from: oldPrecision, to: newPrecision });
|
|
1084
|
+
}
|
|
1085
|
+
const oldScale = oldCol.typeParams?.scale;
|
|
1086
|
+
const newScale = newCol.typeParams?.scale;
|
|
1087
|
+
if (oldScale !== newScale) {
|
|
1088
|
+
changes.push({ field: 'scale', from: oldScale, to: newScale });
|
|
1089
|
+
}
|
|
1075
1090
|
return changes;
|
|
1076
1091
|
}
|
|
1077
1092
|
function compareTableIndexes(oldTable, newTable, tableName, result) {
|
|
@@ -373,6 +373,25 @@ function generateColumnModification(tableName, columnName, changes) {
|
|
|
373
373
|
}
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
|
+
case 'precision':
|
|
377
|
+
case 'scale': {
|
|
378
|
+
if (change.field === 'precision') {
|
|
379
|
+
const newPrec = change.to;
|
|
380
|
+
const scaleChange = changes.find(c => c.field === 'scale');
|
|
381
|
+
const newScale = scaleChange ? scaleChange.to : undefined;
|
|
382
|
+
const oldPrec = change.from;
|
|
383
|
+
const oldScale = scaleChange ? scaleChange.from : undefined;
|
|
384
|
+
const newFullType = newPrec != null
|
|
385
|
+
? (newScale != null ? `NUMERIC(${newPrec}, ${newScale})` : `NUMERIC(${newPrec})`)
|
|
386
|
+
: 'NUMERIC';
|
|
387
|
+
const oldFullType = oldPrec != null
|
|
388
|
+
? (oldScale != null ? `NUMERIC(${oldPrec}, ${oldScale})` : `NUMERIC(${oldPrec})`)
|
|
389
|
+
: 'NUMERIC';
|
|
390
|
+
upSQL.push(`ALTER TABLE "${tableName}" ALTER COLUMN "${columnName}" TYPE ${newFullType};`);
|
|
391
|
+
downSQL.push(`ALTER TABLE "${tableName}" ALTER COLUMN "${columnName}" TYPE ${oldFullType};`);
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
376
395
|
}
|
|
377
396
|
}
|
|
378
397
|
return { upSQL, downSQL };
|
|
@@ -1061,6 +1061,21 @@ function compareColumnProperties(oldCol, newCol) {
|
|
|
1061
1061
|
if (oldCol.defaultValue !== newCol.defaultValue) {
|
|
1062
1062
|
changes.push({ field: 'default', from: oldCol.defaultValue, to: newCol.defaultValue });
|
|
1063
1063
|
}
|
|
1064
|
+
const oldLength = oldCol.typeParams?.length;
|
|
1065
|
+
const newLength = newCol.typeParams?.length;
|
|
1066
|
+
if (oldLength !== newLength) {
|
|
1067
|
+
changes.push({ field: 'length', from: oldLength, to: newLength });
|
|
1068
|
+
}
|
|
1069
|
+
const oldPrecision = oldCol.typeParams?.precision;
|
|
1070
|
+
const newPrecision = newCol.typeParams?.precision;
|
|
1071
|
+
if (oldPrecision !== newPrecision) {
|
|
1072
|
+
changes.push({ field: 'precision', from: oldPrecision, to: newPrecision });
|
|
1073
|
+
}
|
|
1074
|
+
const oldScale = oldCol.typeParams?.scale;
|
|
1075
|
+
const newScale = newCol.typeParams?.scale;
|
|
1076
|
+
if (oldScale !== newScale) {
|
|
1077
|
+
changes.push({ field: 'scale', from: oldScale, to: newScale });
|
|
1078
|
+
}
|
|
1064
1079
|
return changes;
|
|
1065
1080
|
}
|
|
1066
1081
|
function compareTableIndexes(oldTable, newTable, tableName, result) {
|