bun-query-builder 0.2.10 → 0.2.11

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/bin/cli.js CHANGED
@@ -28347,6 +28347,9 @@ ${statement}`);
28347
28347
  existingCorpusBodies?.add(body);
28348
28348
  return true;
28349
28349
  }
28350
+ function isLosslessTypeChange(from, to) {
28351
+ return from === "integer" && to === "bigint" || from === "string" && to === "text";
28352
+ }
28350
28353
  function guessTypeFromName(columnName) {
28351
28354
  if (columnName.endsWith("_id"))
28352
28355
  return "bigint";
@@ -29376,7 +29379,7 @@ function generateDiffOperations(previous, next, opts = {}) {
29376
29379
  kind: "modify_column",
29377
29380
  table: curr.table,
29378
29381
  column: colName,
29379
- destructive: prevCol.type !== currCol.type,
29382
+ destructive: prevCol.type !== currCol.type && !isLosslessTypeChange(prevCol.type, currCol.type),
29380
29383
  sql: modifyColumnStatement
29381
29384
  });
29382
29385
  info2(`-- Detected column change: ${curr.table}.${colName} (${prevCol.type} -> ${currCol.type})`);
@@ -31536,7 +31539,7 @@ function getPrefix() {
31536
31539
  }
31537
31540
  var prefix = getPrefix();
31538
31541
  // package.json
31539
- var version2 = "0.2.10";
31542
+ var version2 = "0.2.11";
31540
31543
 
31541
31544
  // bin/cli.ts
31542
31545
  init_actions();
@@ -10,6 +10,13 @@ export declare function isGeneratedMigrationSql(sql: string): boolean;
10
10
  * the same thing to the schema, whatever they are called.
11
11
  */
12
12
  export declare function migrationBody(sql: string): string;
13
+ /**
14
+ * Whether changing a normalized physical type can preserve every existing
15
+ * value. Keep this deliberately conservative: integer-to-bigint widens the
16
+ * numeric range, and varchar-to-text removes a length ceiling. The reverse
17
+ * directions remain destructive and still require explicit confirmation.
18
+ */
19
+ export declare function isLosslessTypeChange(from: NormalizedColumnType, to: NormalizedColumnType): boolean;
13
20
  export declare function buildMigrationPlan(models: ModelRecord, options: InferenceOptions): MigrationPlan;
14
21
  export declare function generateSql(plan: MigrationPlan, opts?: { dryRun?: boolean }): string[];
15
22
  /**
package/dist/src/index.js CHANGED
@@ -28346,6 +28346,9 @@ ${statement}`);
28346
28346
  existingCorpusBodies?.add(body);
28347
28347
  return true;
28348
28348
  }
28349
+ function isLosslessTypeChange(from, to) {
28350
+ return from === "integer" && to === "bigint" || from === "string" && to === "text";
28351
+ }
28349
28352
  function guessTypeFromName(columnName) {
28350
28353
  if (columnName.endsWith("_id"))
28351
28354
  return "bigint";
@@ -29375,7 +29378,7 @@ function generateDiffOperations(previous, next, opts = {}) {
29375
29378
  kind: "modify_column",
29376
29379
  table: curr.table,
29377
29380
  column: colName,
29378
- destructive: prevCol.type !== currCol.type,
29381
+ destructive: prevCol.type !== currCol.type && !isLosslessTypeChange(prevCol.type, currCol.type),
29379
29382
  sql: modifyColumnStatement
29380
29383
  });
29381
29384
  info2(`-- Detected column change: ${curr.table}.${colName} (${prevCol.type} -> ${currCol.type})`);
@@ -29552,6 +29555,7 @@ export {
29552
29555
  lastCreatedMigrationFiles,
29553
29556
  iterateAllPivots,
29554
29557
  isMysqlLike,
29558
+ isLosslessTypeChange,
29555
29559
  isGeneratedMigrationSql,
29556
29560
  isDefinitionEqual,
29557
29561
  isBrowser,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.2.10",
4
+ "version": "0.2.11",
5
5
  "description": "A simple yet performant query builder for TypeScript. Built with Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",