Modulo makers3d desarrollado con codex V 0.0.1
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { pool } from "../db.js";
|
||||
|
||||
const currentDir = dirname(fileURLToPath(import.meta.url));
|
||||
const schemaCandidates = [
|
||||
join(currentDir, "../db/schema.sql"),
|
||||
join(process.cwd(), "apps/api/src/db/schema.sql"),
|
||||
join(process.cwd(), "dist/apps/api/src/db/schema.sql")
|
||||
];
|
||||
|
||||
let sql: string | undefined;
|
||||
|
||||
for (const schemaPath of schemaCandidates) {
|
||||
try {
|
||||
sql = await readFile(schemaPath, "utf8");
|
||||
break;
|
||||
} catch {
|
||||
// Try the next known location. The runtime container keeps the schema outside dist.
|
||||
}
|
||||
}
|
||||
|
||||
if (!sql) {
|
||||
throw new Error(`Schema file not found. Checked: ${schemaCandidates.join(", ")}`);
|
||||
}
|
||||
|
||||
await pool.query(sql);
|
||||
console.log("Database schema applied");
|
||||
await pool.end();
|
||||
Reference in New Issue
Block a user