feat: add migration scripts for autonomy-audit and roadmap-gen tables

This commit is contained in:
root
2026-03-24 05:13:55 -04:00
parent 6f147590d8
commit 2dcfe605af
2 changed files with 112 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env node
/**
* Migration script: Add triad_metrics and triad_roadmaps tables
*
* Run: node scripts/migrate-autonomy-audit-schema.js
*/
const Database = require('better-sqlite3');
const path = require('path');
const DB_PATH = path.join(process.env.OPENCLAW_DIR || process.cwd(), '.aura', 'consensus.db');
const db = new Database(DB_PATH);
try {
console.log('Creating triad_metrics table...');
db.exec(`
CREATE TABLE IF NOT EXISTS triad_metrics (
id INTEGER PRIMARY KEY AUTOINCREMENT,
autonomy REAL NOT NULL,
consensus REAL NOT NULL,
failover REAL NOT NULL,
knowledge REAL NOT NULL,
growth REAL NOT NULL,
humanBlock REAL NOT NULL,
timestamp INTEGER NOT NULL,
calculated_at TEXT DEFAULT CURRENT_TIMESTAMP
)
`);
console.log('Creating triad_roadmaps table...');
db.exec(`
CREATE TABLE IF NOT EXISTS triad_roadmaps (
id INTEGER PRIMARY KEY AUTOINCREMENT,
period TEXT NOT NULL,
roadmap TEXT NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
)
`);
console.log('Tables created successfully!');
console.log('\nSchema verification:');
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
console.log('Available tables:', tables.map(t => t.name).join(', '));
db.close();
process.exit(0);
} catch (error) {
console.error('Migration failed:', error.message);
db.close();
process.exit(1);
}
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env node
/**
* Migration script: Add triad_metrics and triad_roadmaps tables
*
* Run: npx tsx scripts/migrate-autonomy-audit-schema.mjs
*/
import Database from 'better-sqlite3';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const DB_PATH = path.join(process.env.OPENCLAW_DIR || process.cwd(), '.aura', 'consensus.db');
const db = new Database(DB_PATH);
try {
console.log('Creating triad_metrics table...');
db.exec(`
CREATE TABLE IF NOT EXISTS triad_metrics (
id INTEGER PRIMARY KEY AUTOINCREMENT,
autonomy REAL NOT NULL,
consensus REAL NOT NULL,
failover REAL NOT NULL,
knowledge REAL NOT NULL,
growth REAL NOT NULL,
humanBlock REAL NOT NULL,
timestamp INTEGER NOT NULL,
calculated_at TEXT DEFAULT CURRENT_TIMESTAMP
)
`);
console.log('Creating triad_roadmaps table...');
db.exec(`
CREATE TABLE IF NOT EXISTS triad_roadmaps (
id INTEGER PRIMARY KEY AUTOINCREMENT,
period TEXT NOT NULL,
roadmap TEXT NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
)
`);
console.log('Tables created successfully!');
console.log('\nSchema verification:');
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
console.log('Available tables:', tables.map(t => t.name).join(', '));
db.close();
process.exit(0);
} catch (error) {
console.error('Migration failed:', error.message);
db.close();
process.exit(1);
}