latticesql 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -56,6 +56,8 @@ Lattice has no opinions about your schema, your agents, or your file format. You
56
56
  - [Security](#security)
57
57
  - [Architecture](#architecture)
58
58
  - [Examples](#examples)
59
+ - [Staying up to date](#staying-up-to-date)
60
+ - [Auto-update](#auto-update-v11)
59
61
  - [Contributing](#contributing)
60
62
  - [Changelog](#changelog)
61
63
 
@@ -2022,6 +2024,32 @@ Three complete, commented examples are in [docs/examples/](./docs/examples/):
2022
2024
 
2023
2025
  **Library consumers:** By default, `npm install latticesql` adds a `^` semver range to your `package.json`, so patch and minor updates are picked up on your next `npm install`. For fully automated dependency updates, set up [Dependabot](https://docs.github.com/en/code-security/dependabot) or [Renovate](https://github.com/renovatebot/renovate) — they'll create PRs in your repo whenever a new version is published.
2024
2026
 
2027
+ ### Auto-update (v1.1+)
2028
+
2029
+ For applications that manage their own updates at runtime, `autoUpdate()` checks npm for a newer version and installs it automatically. Call it once at startup, before initializing Lattice:
2030
+
2031
+ ```typescript
2032
+ import { autoUpdate } from 'latticesql';
2033
+
2034
+ // Call at app startup — checks npm, installs if outdated
2035
+ const result = await autoUpdate();
2036
+ if (result.restartRequired) {
2037
+ process.exit(0); // Let process manager restart
2038
+ }
2039
+ ```
2040
+
2041
+ `autoUpdate()` is safe to call on every startup — it skips if already on the latest version. Pass `{ quiet: true }` to suppress console output.
2042
+
2043
+ **`AutoUpdateResult`**
2044
+
2045
+ ```typescript
2046
+ interface AutoUpdateResult {
2047
+ updated: boolean;
2048
+ packages: Array<{ name: string; from: string; to: string }>;
2049
+ restartRequired: boolean;
2050
+ }
2051
+ ```
2052
+
2025
2053
  ---
2026
2054
 
2027
2055
  ## Contributing
package/dist/cli.js CHANGED
@@ -563,7 +563,15 @@ var SchemaManager = class {
563
563
  for (const [col, type] of Object.entries(columns)) {
564
564
  if (!existing.includes(col)) {
565
565
  if (type.toUpperCase().includes("PRIMARY KEY")) continue;
566
- adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${type}`);
566
+ const upperType = type.toUpperCase();
567
+ const hasNonConstantDefault = upperType.includes("CURRENT_TIMESTAMP") || upperType.includes("DATETIME('NOW')") || upperType.includes("RANDOM()");
568
+ if (hasNonConstantDefault) {
569
+ const safeType = type.replace(/\bNOT\s+NULL\b/gi, "").replace(/\bDEFAULT\s+CURRENT_TIMESTAMP\b/gi, "").replace(/\bDEFAULT\s+datetime\([^)]*\)/gi, "").replace(/\bDEFAULT\s+RANDOM\(\)/gi, "").replace(/\s+/g, " ").trim();
570
+ adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${safeType || "TEXT"}`);
571
+ adapter.run(`UPDATE "${table}" SET "${col}" = CURRENT_TIMESTAMP WHERE "${col}" IS NULL`);
572
+ } else {
573
+ adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${type}`);
574
+ }
567
575
  }
568
576
  }
569
577
  }
package/dist/index.cjs CHANGED
@@ -316,7 +316,15 @@ var SchemaManager = class {
316
316
  for (const [col, type] of Object.entries(columns)) {
317
317
  if (!existing.includes(col)) {
318
318
  if (type.toUpperCase().includes("PRIMARY KEY")) continue;
319
- adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${type}`);
319
+ const upperType = type.toUpperCase();
320
+ const hasNonConstantDefault = upperType.includes("CURRENT_TIMESTAMP") || upperType.includes("DATETIME('NOW')") || upperType.includes("RANDOM()");
321
+ if (hasNonConstantDefault) {
322
+ const safeType = type.replace(/\bNOT\s+NULL\b/gi, "").replace(/\bDEFAULT\s+CURRENT_TIMESTAMP\b/gi, "").replace(/\bDEFAULT\s+datetime\([^)]*\)/gi, "").replace(/\bDEFAULT\s+RANDOM\(\)/gi, "").replace(/\s+/g, " ").trim();
323
+ adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${safeType || "TEXT"}`);
324
+ adapter.run(`UPDATE "${table}" SET "${col}" = CURRENT_TIMESTAMP WHERE "${col}" IS NULL`);
325
+ } else {
326
+ adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${type}`);
327
+ }
320
328
  }
321
329
  }
322
330
  }
package/dist/index.js CHANGED
@@ -248,7 +248,15 @@ var SchemaManager = class {
248
248
  for (const [col, type] of Object.entries(columns)) {
249
249
  if (!existing.includes(col)) {
250
250
  if (type.toUpperCase().includes("PRIMARY KEY")) continue;
251
- adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${type}`);
251
+ const upperType = type.toUpperCase();
252
+ const hasNonConstantDefault = upperType.includes("CURRENT_TIMESTAMP") || upperType.includes("DATETIME('NOW')") || upperType.includes("RANDOM()");
253
+ if (hasNonConstantDefault) {
254
+ const safeType = type.replace(/\bNOT\s+NULL\b/gi, "").replace(/\bDEFAULT\s+CURRENT_TIMESTAMP\b/gi, "").replace(/\bDEFAULT\s+datetime\([^)]*\)/gi, "").replace(/\bDEFAULT\s+RANDOM\(\)/gi, "").replace(/\s+/g, " ").trim();
255
+ adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${safeType || "TEXT"}`);
256
+ adapter.run(`UPDATE "${table}" SET "${col}" = CURRENT_TIMESTAMP WHERE "${col}" IS NULL`);
257
+ } else {
258
+ adapter.run(`ALTER TABLE "${table}" ADD COLUMN "${col}" ${type}`);
259
+ }
252
260
  }
253
261
  }
254
262
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latticesql",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Persistent structured memory for AI agent systems — SQLite ↔ LLM context bridge",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",