MCPcopy
hub / github.com/different-ai/openwork / ensureSchema

Function ensureSchema

evals/runner/den-stack.mjs:153–171  ·  view source on GitHub ↗
(log)

Source from the content-addressed store, hash-verified

151}
152
153async function ensureSchema(log) {
154 try {
155 const tables = await mysqlQuery("SHOW TABLES LIKE 'organization';");
156 if (tables.includes("organization")) {
157 log("Schema present");
158 return;
159 }
160 } catch {
161 // Database may not exist yet — push will create what it needs.
162 }
163 log("Pushing schema (first run takes a minute)...");
164 const denDbDir = join(REPO_ROOT, "ee", "packages", "den-db");
165 await run("pnpm", ["--filter", "@openwork-ee/den-db", "build"]);
166 await run("node", ["--import", "tsx", "./node_modules/drizzle-kit/bin.cjs", "push", "--config", "drizzle.config.ts"], {
167 cwd: denDbDir,
168 env: { ...process.env, DATABASE_URL: DEN_ENV.DATABASE_URL, DEN_DB_ENCRYPTION_KEY: DEN_ENV.DEN_DB_ENCRYPTION_KEY },
169 });
170 log("Schema pushed");
171}
172
173async function ensureDenApi(log) {
174 if (await httpOk(`${DEN_API_URL}/health`)) {

Callers 1

ensureDenStackFunction · 0.85

Calls 3

mysqlQueryFunction · 0.85
runFunction · 0.70
logFunction · 0.50

Tested by

no test coverage detected