Add ECDSA signature verification and enhance ComboHandler functionality
- Integrated ECDSA for signature verification in ComboHandler. - Updated event emissions to include additional parameters for better tracking. - Improved gas tracking during execution of combo plans. - Enhanced database interactions for storing and retrieving plans, including conflict resolution and status updates. - Added new dependencies for security and database management in orchestrator.
This commit is contained in:
47
orchestrator/src/db/migrations/001_initial_schema.ts
Normal file
47
orchestrator/src/db/migrations/001_initial_schema.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { query } from "../postgres";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
/**
|
||||
* Run initial database schema migration
|
||||
*/
|
||||
export async function up() {
|
||||
const schemaPath = path.join(__dirname, "../schema.sql");
|
||||
const schema = fs.readFileSync(schemaPath, "utf-8");
|
||||
|
||||
// Split by semicolons and execute each statement
|
||||
const statements = schema
|
||||
.split(";")
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s.length > 0 && !s.startsWith("--"));
|
||||
|
||||
for (const statement of statements) {
|
||||
try {
|
||||
await query(statement);
|
||||
} catch (error: any) {
|
||||
// Ignore "already exists" errors
|
||||
if (!error.message.includes("already exists")) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("✅ Database schema migrated successfully");
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback migration (not implemented for initial schema)
|
||||
*/
|
||||
export async function down() {
|
||||
// Drop tables in reverse order
|
||||
await query("DROP TABLE IF EXISTS compliance_status CASCADE");
|
||||
await query("DROP TABLE IF EXISTS users CASCADE");
|
||||
await query("DROP TABLE IF EXISTS audit_logs CASCADE");
|
||||
await query("DROP TABLE IF EXISTS receipts CASCADE");
|
||||
await query("DROP TABLE IF EXISTS executions CASCADE");
|
||||
await query("DROP TABLE IF EXISTS plans CASCADE");
|
||||
await query("DROP FUNCTION IF EXISTS update_updated_at_column CASCADE");
|
||||
|
||||
console.log("✅ Database schema rolled back");
|
||||
}
|
||||
|
||||
15
orchestrator/src/db/migrations/index.ts
Normal file
15
orchestrator/src/db/migrations/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { up as up001 } from "./001_initial_schema";
|
||||
|
||||
/**
|
||||
* Run all migrations
|
||||
*/
|
||||
export async function runMigration() {
|
||||
try {
|
||||
await up001();
|
||||
console.log("✅ All migrations completed");
|
||||
} catch (error) {
|
||||
console.error("❌ Migration failed:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user