@vertz/db 0.2.19 → 0.2.20

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 CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  parsePgError,
30
30
  resolveSelectColumns,
31
31
  validateIndexes
32
- } from "./shared/chunk-1x9z0p5e.js";
32
+ } from "./shared/chunk-kzmhe7pw.js";
33
33
  import"./shared/chunk-kb4tnn2k.js";
34
34
  import {
35
35
  PostgresDialect,
package/dist/internals.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  mapRow,
10
10
  mapRows,
11
11
  resolveSelectColumns
12
- } from "./shared/chunk-1x9z0p5e.js";
12
+ } from "./shared/chunk-kzmhe7pw.js";
13
13
  import {
14
14
  NodeSnapshotStorage
15
15
  } from "./shared/chunk-kb4tnn2k.js";
@@ -357,24 +357,22 @@ function isEnumType(col, enums) {
357
357
  return false;
358
358
  }
359
359
  function getEnumValues(col, enums) {
360
- if (!enums)
361
- return;
362
360
  for (const [enumName, values] of Object.entries(enums)) {
363
361
  if (col.type.toLowerCase() === enumName.toLowerCase() || col.type === enumName) {
364
362
  return values;
365
363
  }
366
364
  }
367
- return;
365
+ return [];
368
366
  }
369
367
  function columnDef(name, col, dialect, enums) {
370
368
  const snakeName = camelToSnake(name);
371
369
  const isEnum = isEnumType(col, enums);
372
370
  let sqlType;
373
371
  let checkConstraint;
374
- if (isEnum && dialect.name === "sqlite") {
372
+ if (isEnum && enums && dialect.name === "sqlite") {
375
373
  sqlType = dialect.mapColumnType("text");
376
374
  const enumValues = getEnumValues(col, enums);
377
- if (enumValues && enumValues.length > 0) {
375
+ if (enumValues.length > 0) {
378
376
  const escapedValues = enumValues.map((v) => `'${escapeSqlString(v)}'`).join(", ");
379
377
  checkConstraint = `CHECK("${snakeName}" IN (${escapedValues}))`;
380
378
  }
@@ -458,7 +456,7 @@ function generateMigrationSql(changes, ctx, dialect = defaultPostgresDialect) {
458
456
  for (const [, col] of Object.entries(table.columns)) {
459
457
  if (isEnumType(col, enums)) {
460
458
  const enumValues = getEnumValues(col, enums);
461
- if (enumValues && enumValues.length > 0) {
459
+ if (enumValues.length > 0) {
462
460
  const enumSnakeName = camelToSnake(col.type);
463
461
  const alreadyEmitted = statements.some((s) => s.includes(`CREATE TYPE "${enumSnakeName}"`));
464
462
  if (!alreadyEmitted) {
@@ -617,11 +615,6 @@ async function autoMigrate(options) {
617
615
  console.log("[auto-migrate] No previous snapshot found. Applying full schema...");
618
616
  const diff = computeDiff({ version: 1, tables: {}, enums: {} }, currentSchema);
619
617
  if (diff.changes.length > 0) {
620
- for (const change of diff.changes) {
621
- if (isDestructiveChange(change)) {
622
- console.warn(`[auto-migrate] Warning: Destructive change detected on first run: ${change.type}`);
623
- }
624
- }
625
618
  const sql = generateMigrationSql(diff.changes, {
626
619
  tables: currentSchema.tables,
627
620
  enums: currentSchema.enums
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertz/db",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Database layer for Vertz — typed queries, migrations, codegen",