@stacksjs/database 0.70.205 → 0.70.206

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.
Files changed (2) hide show
  1. package/dist/migrations.js +10 -5
  2. package/package.json +11 -11
@@ -493,9 +493,11 @@ export async function previewPendingMigrations(options = {}) {
493
493
  return [];
494
494
  }
495
495
  }
496
+ function snapshotDirLabel() {
497
+ return qbConfig?.snapshotDir || QB_SNAPSHOT_DIR;
498
+ }
496
499
  function resolveSnapshotDir() {
497
- const configured = qbConfig?.snapshotDir;
498
- return join(process.cwd(), configured || QB_SNAPSHOT_DIR);
500
+ return join(process.cwd(), snapshotDirLabel());
499
501
  }
500
502
  function detectSnapshotDialectMismatch(dialect) {
501
503
  const qbDir = resolveSnapshotDir();
@@ -520,8 +522,10 @@ export async function generateMigrations(options = {}) {
520
522
  log.debug("Generating migrations...");
521
523
  configureQueryBuilder();
522
524
  const dialect = getDialect(), mismatch = detectSnapshotDialectMismatch(dialect);
523
- if (mismatch)
524
- return err(Error(`Refusing to generate migrations: resolved dialect "${dialect}" has no snapshot in .qb/, but "${mismatch}" does. DB_CONNECTION is likely unset or wrong (missing .env?) \u2014 ` + `generating now would write a full duplicate migration set in the wrong dialect. Set DB_CONNECTION=${mismatch} (or your intended dialect) and retry. To intentionally start a new dialect from scratch, remove .qb/model-snapshot.${mismatch}.json first.`));
525
+ if (mismatch) {
526
+ const snapshotDir = snapshotDirLabel();
527
+ return err(Error(`Refusing to generate migrations: resolved dialect "${dialect}" has no snapshot in ${snapshotDir}/, but "${mismatch}" does. DB_CONNECTION is likely unset or wrong ` + "(missing .env?) \u2014 generating now would write a full duplicate migration set in the " + `wrong dialect. Set DB_CONNECTION=${mismatch} (or your intended dialect) and retry. To intentionally start a new dialect from scratch, remove ${snapshotDir}/model-snapshot.${mismatch}.json first.`));
528
+ }
525
529
  const { modelsDir, skip } = prepareMigrationModelsDir();
526
530
  if (skip) {
527
531
  log.debug("No app/Models directory found; using committed framework migrations");
@@ -563,13 +567,14 @@ export function findDanglingTypeReferences(statements) {
563
567
  }
564
568
  export async function regenerateMigrationCorpus(options = {}) {
565
569
  try {
570
+ configureQueryBuilder();
566
571
  const dialect = options.dialect ?? getQbDialect(), dir = options.dir ?? join(process.cwd(), "database", "migrations"), sources = resolveModelSources();
567
572
  if (!sources)
568
573
  return err(Error("No models found. Define models in app/Models, or ensure the framework defaults at storage/framework/defaults/app/Models are present."));
569
574
  try {
570
575
  writeFileSync(join(sources.dir, `.qb-migrations.${dialect}.json`), JSON.stringify({ plan: { dialect, tables: [] } }));
571
576
  } catch {}
572
- const snapshotPath = join(process.cwd(), ".qb", `model-snapshot.${dialect}.json`), parkedSnapshot = `${snapshotPath}.regenerating`;
577
+ const snapshotPath = join(resolveSnapshotDir(), `model-snapshot.${dialect}.json`), parkedSnapshot = `${snapshotPath}.regenerating`;
573
578
  let snapshotParked = !1;
574
579
  if (existsSync(snapshotPath))
575
580
  try {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/database",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.205",
5
+ "version": "0.70.206",
6
6
  "description": "The Stacks database integration.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -56,19 +56,19 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@stacksjs/ts-validation": "^0.5.0",
59
- "bun-query-builder": "^0.1.59",
59
+ "bun-query-builder": "^0.1.63",
60
60
  "dynamodb-tooling": "^0.3.2"
61
61
  },
62
62
  "devDependencies": {
63
- "@stacksjs/cli": "0.70.205",
64
- "@stacksjs/config": "0.70.205",
65
- "@stacksjs/logging": "0.70.205",
66
- "@stacksjs/router": "0.70.205",
63
+ "@stacksjs/cli": "0.70.206",
64
+ "@stacksjs/config": "0.70.206",
65
+ "@stacksjs/logging": "0.70.206",
66
+ "@stacksjs/router": "0.70.206",
67
67
  "better-dx": "^0.2.17",
68
- "@stacksjs/path": "0.70.205",
69
- "@stacksjs/query-builder": "0.70.205",
70
- "@stacksjs/storage": "0.70.205",
71
- "@stacksjs/strings": "0.70.205",
72
- "@stacksjs/utils": "0.70.205"
68
+ "@stacksjs/path": "0.70.206",
69
+ "@stacksjs/query-builder": "0.70.206",
70
+ "@stacksjs/storage": "0.70.206",
71
+ "@stacksjs/strings": "0.70.206",
72
+ "@stacksjs/utils": "0.70.206"
73
73
  }
74
74
  }