nexusql 0.9.7 → 0.9.8

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.js CHANGED
@@ -3224,7 +3224,7 @@ var Database = class _Database {
3224
3224
  [ext]
3225
3225
  );
3226
3226
  if (!result.rows[0]?.exists) {
3227
- throw new Error(`Extension "${ext}" was not installed`);
3227
+ throw new Error(`Extension ${quotedExt} was not installed`);
3228
3228
  }
3229
3229
  } catch (error) {
3230
3230
  const message = error instanceof Error ? error.message : String(error);
@@ -3414,8 +3414,16 @@ async function gen(options = {}) {
3414
3414
  const tempDb = db.withDatabase(tempDbName);
3415
3415
  let migrationSql = "";
3416
3416
  try {
3417
+ const hasVectorType = targetSql.toLowerCase().includes("vector");
3418
+ const extensions = [...config.extensions];
3419
+ if (hasVectorType && !extensions.includes("vector")) {
3420
+ spinner.info(
3421
+ "Detected 'vector' type usage - auto-enabling vector extension"
3422
+ );
3423
+ extensions.push("vector");
3424
+ }
3417
3425
  spinner.start("Installing extensions...");
3418
- await tempDb.installExtensions(config.extensions);
3426
+ await tempDb.installExtensions(extensions);
3419
3427
  if (config.extensions.includes("vector")) {
3420
3428
  const vectorCheck = await tempDb.query(
3421
3429
  "SELECT typname FROM pg_type WHERE typname = 'vector'"
@@ -3430,9 +3438,7 @@ async function gen(options = {}) {
3430
3438
  spinner.succeed("Installed db extensions");
3431
3439
  spinner.start("Loading schema into temp database...");
3432
3440
  if (targetSql.toLowerCase().includes("vector")) {
3433
- const vectorLines = targetSql.split("\n").filter(
3434
- (line) => line.toLowerCase().includes("vector")
3435
- );
3441
+ const vectorLines = targetSql.split("\n").filter((line) => line.toLowerCase().includes("vector"));
3436
3442
  console.log("\n[DEBUG] SQL lines with 'vector':");
3437
3443
  vectorLines.forEach((line) => console.log(" ", line.trim()));
3438
3444
  console.log("");