astrocode-workflow 0.1.11 → 0.1.12
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/state/db.js +14 -0
- package/package.json +1 -1
- package/src/state/db.ts +13 -0
package/dist/state/db.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { SCHEMA_SQL, SCHEMA_VERSION } from "./schema";
|
|
4
4
|
import { nowISO } from "../shared/time";
|
|
5
|
+
import { info } from "../shared/log";
|
|
5
6
|
import { createDatabaseAdapter } from "./adapters";
|
|
6
7
|
/** Ensure directory exists for a file path. */
|
|
7
8
|
function ensureParentDir(filePath) {
|
|
@@ -55,6 +56,19 @@ export function ensureSchema(db, opts) {
|
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
57
58
|
db.exec(SCHEMA_SQL);
|
|
59
|
+
// Migrations for existing databases
|
|
60
|
+
// Add created_at to stage_runs if missing (introduced in schema version 2)
|
|
61
|
+
try {
|
|
62
|
+
const columns = db.prepare("PRAGMA table_info(stage_runs)").all();
|
|
63
|
+
const hasCreatedAt = columns.some(col => col.name === 'created_at');
|
|
64
|
+
if (!hasCreatedAt) {
|
|
65
|
+
db.exec("ALTER TABLE stage_runs ADD COLUMN created_at TEXT NOT NULL DEFAULT ''");
|
|
66
|
+
info("[Astrocode] Added created_at column to stage_runs table");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
// Column might already exist or table doesn't exist, ignore
|
|
71
|
+
}
|
|
58
72
|
const row = db.prepare("SELECT schema_version FROM repo_state WHERE id = 1").get();
|
|
59
73
|
if (!row) {
|
|
60
74
|
const now = nowISO();
|
package/package.json
CHANGED
package/src/state/db.ts
CHANGED
|
@@ -68,6 +68,19 @@ export function ensureSchema(db: SqliteDb, opts?: { allowAutoMigrate?: boolean;
|
|
|
68
68
|
try {
|
|
69
69
|
db.exec(SCHEMA_SQL);
|
|
70
70
|
|
|
71
|
+
// Migrations for existing databases
|
|
72
|
+
// Add created_at to stage_runs if missing (introduced in schema version 2)
|
|
73
|
+
try {
|
|
74
|
+
const columns = db.prepare("PRAGMA table_info(stage_runs)").all() as { name: string }[];
|
|
75
|
+
const hasCreatedAt = columns.some(col => col.name === 'created_at');
|
|
76
|
+
if (!hasCreatedAt) {
|
|
77
|
+
db.exec("ALTER TABLE stage_runs ADD COLUMN created_at TEXT NOT NULL DEFAULT ''");
|
|
78
|
+
info("[Astrocode] Added created_at column to stage_runs table");
|
|
79
|
+
}
|
|
80
|
+
} catch (e) {
|
|
81
|
+
// Column might already exist or table doesn't exist, ignore
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
const row = db.prepare("SELECT schema_version FROM repo_state WHERE id = 1").get() as { schema_version?: number } | undefined;
|
|
72
85
|
|
|
73
86
|
if (!row) {
|