(log)
| 151 | } |
| 152 | |
| 153 | async 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 | |
| 173 | async function ensureDenApi(log) { |
| 174 | if (await httpOk(`${DEN_API_URL}/health`)) { |
no test coverage detected