Skip to content
fusion-db

Schema

fusion-db owns the foundation schema — the entity-agnostic tables every Fusion app needs. App-specific tables live in the consuming app; the foundation never references them, so the dependency only ever points one way (app → foundation).

The foundation tables

The Better Auth core (user / session / account / verification), with apiToken for non-browser clients:

Loading diagram...

Alongside these the foundation also ships mailbox (a simulated outbox), auditLog (an explicit change-history layer) and appConfig (runtime key/value settings).

Defined as Drizzle tables

Each table is a plain Drizzle definition. This is the real user table, embedded straight from the source — so the docs can't drift from the code:

foundation.ts
export const user = pgTable("user", {
	id: text("id").primaryKey(),
	name: text("name").notNull(),
	email: text("email").notNull().unique(),
	emailVerified: boolean("email_verified").notNull().default(false),
	image: text("image"),
	isSiteAdmin: boolean("is_site_admin").notNull().default(false),
	deactivatedAt: timestamp("deactivated_at"),
	// Free-form per-user key/value store. Used by `user_info` tasks to persist
	// collected field values (keyed by `task:<id>`); other future profile data
	// can live here too.
	metadata: jsonb("metadata"),
	createdAt: timestamp("created_at").notNull().defaultNow(),
	updatedAt: timestamp("updated_at").notNull().defaultNow(),
});

Types come for free

Drizzle infers row types from the table definition — no hand-written interfaces. Hover User:

import { , , , ,  } from "drizzle-orm/pg-core";
 
const  = ("user", {
  : ("id").(),
  : ("name").(),
  : ("email").().(),
  : ("email_verified").().(false),
  : ("metadata"),
  : ("created_at").().(),
});
 
type  = typeof .;

fusion-db re-exports these row types (User, Mailbox, ApiToken, …) next to the tables, so your app code stays fully typed end to end.

Two entry points

ImportUse it when
@tikab-interactive/fusion-db/foundationyou only need the reusable foundation tables
@tikab-interactive/fusion-db/schemayou need the foundation plus the app's composed domain

Migrations live in the app

The schema lives here; migrations live in the consuming app. An app points its own drizzle.config.ts at @tikab-interactive/fusion-db/schema, composes its domain tables on top, and owns the generated drizzle/ directory — so a fresh app gets a single 0000 migration covering the foundation and its own tables together.