- Add PostgreSQL database schema (users, subscriptions, tenants, sessions) - Implement authentication service with Argon2id password hashing - Add JWT-based session management with access/refresh tokens - Create REST API routes (auth, agent, usage, billing) - Add encryption utilities (AES-256-GCM) and Vault integration - Set up Docker Compose development environment - Add Hono-based API server with middleware This establishes the foundation for transforming moltbot into a multi-tenant SaaS platform with secure authentication and per-tenant encryption. https://claude.ai/code/session_01UzVUSnxfEecZE8Yes3Zqw9
32 lines
735 B
TypeScript
32 lines
735 B
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { createDbClient } from "./client.js";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
async function migrate() {
|
|
console.log("Starting database migration...");
|
|
|
|
const db = createDbClient();
|
|
|
|
try {
|
|
// Read the schema file
|
|
const schemaPath = path.join(__dirname, "schema.sql");
|
|
const schema = fs.readFileSync(schemaPath, "utf-8");
|
|
|
|
// Execute the schema
|
|
console.log("Executing schema...");
|
|
await db.query(schema);
|
|
|
|
console.log("Migration completed successfully!");
|
|
} catch (error) {
|
|
console.error("Migration failed:", error);
|
|
process.exit(1);
|
|
} finally {
|
|
await db.end();
|
|
}
|
|
}
|
|
|
|
migrate();
|