@stacksjs/database 0.70.202 → 0.70.204

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/database.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { QB_SNAPSHOT_DIR } from "./utils";
1
2
  import { createQueryBuilder, setConfig } from "@stacksjs/query-builder";
2
3
  import { env as stacksEnv } from "@stacksjs/env";
3
4
 
@@ -39,6 +40,7 @@ export class Database {
39
40
  if (this._initialized)
40
41
  return;
41
42
  setConfig({
43
+ snapshotDir: QB_SNAPSHOT_DIR,
42
44
  dialect: this._options.driver,
43
45
  database: this._options.connection,
44
46
  verbose: this._options.verbose,
@@ -20,7 +20,7 @@ import {
20
20
  saveMigrationSnapshot,
21
21
  setConfig
22
22
  } from "@stacksjs/query-builder";
23
- import { db } from "./utils";
23
+ import { db, QB_SNAPSHOT_DIR } from "./utils";
24
24
  import {
25
25
  classifyConnectionError,
26
26
  createDatabase,
@@ -62,7 +62,7 @@ function configureQueryBuilder() {
62
62
  setConfig({
63
63
  dialect,
64
64
  verbose: !1,
65
- snapshotDir: "storage/framework/database",
65
+ snapshotDir: QB_SNAPSHOT_DIR,
66
66
  database: {
67
67
  database: connectionConfig?.name || connectionConfig?.database || "stacks",
68
68
  host: connectionConfig?.host || "localhost",
@@ -494,7 +494,7 @@ export async function previewPendingMigrations(options = {}) {
494
494
  }
495
495
  function resolveSnapshotDir() {
496
496
  const configured = qbConfig?.snapshotDir;
497
- return join(process.cwd(), configured || ".qb");
497
+ return join(process.cwd(), configured || QB_SNAPSHOT_DIR);
498
498
  }
499
499
  function detectSnapshotDialectMismatch(dialect) {
500
500
  const qbDir = resolveSnapshotDir();
package/dist/utils.d.ts CHANGED
@@ -4,6 +4,19 @@ export declare function acquireDbConfigLock(): Promise<() => void>;
4
4
  export declare function initializeDbConfig(config: any): void;
5
5
  export declare function ensureDatabaseConfigLoaded(): Promise<void>;
6
6
  declare function getDb(): ReturnType<typeof createQueryBuilder>;
7
+ /**
8
+ * Update bun-query-builder configuration
9
+ */
10
+ /**
11
+ * Where the model snapshot lives, relative to the project root.
12
+ *
13
+ * Exported and referenced by every `setConfig` call rather than repeated at
14
+ * each one: `setConfig` replaces the query-builder config wholesale, so a call
15
+ * site that omits this silently reverts the snapshot to the library default
16
+ * and writes `.qb` into the project root. That has now happened twice from two
17
+ * different call sites, which is a sign the value wants one home.
18
+ */
19
+ export declare const QB_SNAPSHOT_DIR: 'storage/framework/database';
7
20
  /**
8
21
  * Lazy proxy for the query builder - connection is only made when first used.
9
22
  * This is the main entry point for database operations.
package/dist/utils.js CHANGED
@@ -87,12 +87,14 @@ function getDbConfig() {
87
87
  }
88
88
  return { database: ":memory:" };
89
89
  }
90
+ export const QB_SNAPSHOT_DIR = "storage/framework/database";
90
91
  function updateQueryBuilderConfig() {
91
92
  const dialect = getDialect(), dbConfigForQb = getDbConfig();
92
93
  setConfig({
93
94
  dialect,
94
95
  database: dbConfigForQb,
95
96
  verbose: getEnv() !== "production",
97
+ snapshotDir: QB_SNAPSHOT_DIR,
96
98
  timestamps: {
97
99
  createdAt: "created_at",
98
100
  updatedAt: "updated_at",
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.202",
5
+ "version": "0.70.204",
6
6
  "description": "The Stacks database integration.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -60,15 +60,15 @@
60
60
  "dynamodb-tooling": "^0.3.2"
61
61
  },
62
62
  "devDependencies": {
63
- "@stacksjs/cli": "0.70.202",
64
- "@stacksjs/config": "0.70.202",
65
- "@stacksjs/logging": "0.70.202",
66
- "@stacksjs/router": "0.70.202",
63
+ "@stacksjs/cli": "0.70.204",
64
+ "@stacksjs/config": "0.70.204",
65
+ "@stacksjs/logging": "0.70.204",
66
+ "@stacksjs/router": "0.70.204",
67
67
  "better-dx": "^0.2.17",
68
- "@stacksjs/path": "0.70.202",
69
- "@stacksjs/query-builder": "0.70.202",
70
- "@stacksjs/storage": "0.70.202",
71
- "@stacksjs/strings": "0.70.202",
72
- "@stacksjs/utils": "0.70.202"
68
+ "@stacksjs/path": "0.70.204",
69
+ "@stacksjs/query-builder": "0.70.204",
70
+ "@stacksjs/storage": "0.70.204",
71
+ "@stacksjs/strings": "0.70.204",
72
+ "@stacksjs/utils": "0.70.204"
73
73
  }
74
74
  }