Skip to content

feat(cli): dev defaults to sqlite + auto-seed admin#1455

Merged
xuyushun441-sys merged 2 commits into
mainfrom
fix/dev-default-sqlite-and-seed-admin
Jun 1, 2026
Merged

feat(cli): dev defaults to sqlite + auto-seed admin#1455
xuyushun441-sys merged 2 commits into
mainfrom
fix/dev-default-sqlite-and-seed-admin

Conversation

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

What

Two dev-experience fixes in the CLI so a bare objectstack dev (e.g. pnpm dev:showcase) starts production-like and logged-in by default.

1. dev default driver → SQLite (was in-memory)

In dev with no OS_DATABASE_URL / OS_DATABASE_DRIVER, serve.ts previously defaulted to the pure-JS InMemoryDriver (mingo) — which diverges from real SQL semantics, so "works in dev" didn't guarantee "works in prod". Now it prefers SqlDriver(sqlite, :memory:).

  • Probes by actually opening a connection (connect()SELECT 1), because knex loads better-sqlite3 lazily at first query, not at construction.
  • Falls back to InMemoryDriver with a visible warning if the native binary is unavailable (not built / ABI mismatch after a Node upgrade / blocked prebuild download). This also closes a latent hole where the surrounding silent catch could leave the kernel with no driver.

2. --seed-admin defaults ON in dev

A bare dev never seeded the initial admin, so you always hit the first-run sign-up wizard. Now --seed-admin defaults ON.

  • Idempotent & non-destructive: POSTs the public sign-up endpoint, which creates admin@objectos.ai / admin123 only on an empty DB (then bootstrapPlatformAdmin promotes that first user to platform admin), and skips when the email already exists (422/400) — a custom password is never overwritten.
  • No gating on ephemeral vs persistent needed: seeding an empty DB is exactly what you want; a populated DB is left untouched.
  • Disable with --no-seed-admin.

Verification

  • tsc --noEmit + build green.
  • Bare pnpm dev:showcase: banner shows Driver: SqlDriver(sqlite) → :memory: and 🔑 Admin seeded: admin@objectos.ai / admin123.
  • Persistent file DB run twice: run 1 seeds the admin; run 2 logs (admin admin@objectos.ai already exists — skipping seed) — no overwrite, no error.

🤖 Generated with Claude Code

serve.ts: in dev with no OS_DATABASE_URL/OS_DATABASE_DRIVER, prefer
SqlDriver(sqlite, :memory:) over the pure-JS InMemoryDriver for
production-like SQL semantics. Probe by actually opening a connection
(knex loads better-sqlite3 lazily at first query), and fall back to
InMemoryDriver with a warning if the native binary is unavailable
(not built / ABI mismatch / blocked prebuild). This keeps the
silent-catch path from ever leaving the kernel with no driver.

dev.ts: `--seed-admin` now defaults ON in dev. The seed is idempotent
and non-destructive — it POSTs the public sign-up endpoint, which
creates admin@objectos.ai only on an empty DB (then bootstrapPlatformAdmin
promotes it to platform admin) and skips when the email already exists
(422/400), so a custom password is never overwritten. No need to gate on
ephemeral vs persistent. Disable with --no-seed-admin.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 1, 2026 8:04am

Request Review

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling labels Jun 1, 2026
@xuyushun441-sys xuyushun441-sys merged commit 70b63f2 into main Jun 1, 2026
7 of 8 checks passed
@xuyushun441-sys xuyushun441-sys deleted the fix/dev-default-sqlite-and-seed-admin branch June 1, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants