Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: enhance migration script to load environment variables from .env.local

nirholas7ba6ca91dbbf
diff --git a/scripts/apply-migrations.mjs b/scripts/apply-migrations.mjs
index db581816b..e0f19b802 100755
--- a/scripts/apply-migrations.mjs
+++ b/scripts/apply-migrations.mjs
@@ -17,6 +17,7 @@
*/
import { readFile, readdir } from 'node:fs/promises';
+import { readFileSync } from 'node:fs';
import { createHash } from 'node:crypto';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
@@ -25,7 +26,20 @@ import ws from 'ws';
neonConfig.webSocketConstructor = ws;
const HERE = path.dirname(fileURLToPath(import.meta.url));
-const MIG_DIR = path.resolve(HERE, '..', 'api', '_lib', 'migrations');
+const REPO_ROOT = path.resolve(HERE, '..');
+const MIG_DIR = path.resolve(REPO_ROOT, 'api', '_lib', 'migrations');
+
+// Load .env.local if present (same pattern as seed-skills.js)
+for (const envFile of ['.env.local', '.env']) {
+ try {
+ const raw = readFileSync(path.resolve(REPO_ROOT, envFile), 'utf8');
+ for (const line of raw.split('\n')) {
+ const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
+ if (m && !process.env[m[1]]) process.env[m[1]] = m[2].trim();
+ }
+ break;
+ } catch { /* file not present */ }
+}
const args = process.argv.slice(2);
const APPLY = args.includes('--apply');
@@ -33,7 +47,7 @@ const fileArgIdx = args.indexOf('--file');
const ONLY = fileArgIdx >= 0 ? args[fileArgIdx + 1] : null;
if (!process.env.DATABASE_URL) {
- console.error('DATABASE_URL is not set.');
+ console.error('DATABASE_URL is not set. Add it to .env.local or export it in your shell.');
process.exit(2);
}