Database
The tables the plugin creates, every column, and how they are indexed.
Better Enrollment adds two tables, invite and inviteUse, and extends the organization plugin's organization table when org features are enabled. Run npx auth generate (or npx @better-auth/cli generate on Better Auth 1.6 and earlier) after installing to add them to your schema.
invite
One row per invitation. Status is only ever pending, accepted, or cancelled; expired is derived from expiresAt at read time, so there is no cron and nothing to sweep.
inviteUse
Append-only audit table: one row per redemption. Rows are never updated, and they cascade only when their invite is deleted.
organization (extension)
Columns added to the organization plugin's table, and only when org features are configured, so apps without the org plugin never get stray columns.
user (extension)
Each configured additional field becomes a column on the user table, named after the field and typed by its type. Columns are always nullable: pre-created and open-mode users exist before redemption collects a value, so requiredness is enforced by the redeem flow rather than the database.
Indexes
The schema indexes email, organizationId, tokenHash (unique), status, expiresAt, and createdByUserId. If your invite table grows into the millions, consider adding composite indexes (email, status) and (organizationId, status) in your own migrations. Better Auth 1.7 can declare multi-column indexes in a plugin schema, but the plugin keeps to single-column ones so the same schema still works on 1.4 to 1.6.
Schema validation on Better Auth 1.7
From Better Auth 1.7, the auth instance checks your database schema against what Better Auth and its plugins expect when it starts. Auth requests wait for that check and fail if it finds a mismatch, so a missing invite column now fails every auth request instead of only the invite flows. A mismatch is remembered and returned on every later request until Better Auth's own migration runs or the process restarts.
- Kysely (the built-in adapter): the live database is inspected. Run
npx auth migrateafter upgrading the plugin. - Prisma and Drizzle: your local schema metadata is compared, without a database connection. For Prisma that means the generated client, so after
npx auth generate, also runprisma generateand apply the migration before you deploy.
The check is on by default. advanced.database.validateSchema: false turns it off, but treat that as a temporary escape hatch: the mismatch it hides is still there.
Prisma example
A complete Prisma schema example lives in examples/prisma.
Last updated on