App Logo
Reference

Database Schema

Core Authula database tables

Authula comes with a few core tables that power authentication, account linking, session persistence, and verification workflows. These tables are created automatically by the migrator and are shared across the framework.

How These Tables Fit Together

  • users stores the primary identity record for each authenticated person.
  • accounts stores login methods and external provider credentials linked to a user.
  • sessions stores active sessions for request authentication.
  • verifications stores short-lived workflow records such as email verification, password reset, magic link sign-in and more.

In practice, a user may have one or more linked accounts, one or more sessions, and zero or more verification records depending on which Authula features are enabled.

Database Schema

Table: users

The users table is the root identity record in Authula. It stores profile data and metadata that can be shared across authentication methods.

FieldTypeKeyDescription
idstringPKUnique identifier for the user
namestring-Display name for the user
emailstring-Primary email address
email_verifiedboolean-Whether the email address is verified
imagestring?-Optional profile image URL
metadatajson/jsonb-Arbitrary user metadata
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

Table: accounts

The accounts table stores authentication credentials and linked provider data for each user. It is used for both local credentials and external identity providers.

FieldTypeKeyDescription
idstringPKUnique identifier for the account
user_idstringFKUser that owns this account
account_idstring-Provider-specific account identifier
provider_idstring-Authentication provider identifier
access_tokenstring?-Optional provider access token
refresh_tokenstring?-Optional provider refresh token
id_tokenstring?-Optional OIDC ID token
access_token_expires_attimestamp?-When the access token expires
refresh_token_expires_attimestamp?-When the refresh token expires
scopestring?-Granted OAuth scope
passwordstring?-Password hash for email/password auth
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

accounts.user_id belongs to users.id. For external providers, account_id and provider_id identify the linked identity. For email/password auth, the password column stores the credential material used for password verification.

Table: sessions

The sessions table stores active authenticated sessions so Authula can validate requests and maintain login state across requests.

FieldTypeKeyDescription
idstringPKUnique identifier for the session
user_idstringFKUser that owns the session
tokenstring-Session token used for authentication
expires_attimestamp-When the session expires
ip_addressstring?-Optional source IP address
user_agentstring?-Optional user agent string
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

sessions.user_id belongs to users.id. Sessions are short-lived compared with users and are typically revoked or expired independently of the user record.

Table: verifications

The verifications table stores transient workflow records used for email and multi-step authentication flows.

FieldTypeKeyDescription
idstringPKUnique identifier for the verification record
user_idstring?FKOptional related user
identifierstring-Email or other identifier
tokenstring-Verification token
typeverification_type-Verification workflow type
expires_attimestamp-When the verification expires
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

verifications.user_id belongs to users.id when a verification is tied to an existing user. The identifier field usually stores an email address, and type indicates which workflow created the record.

Verification Types

The type field in verifications stores one of the following values:

TypeMeaning
email_verificationConfirms ownership of an email address
password_reset_requestTracks a password reset flow
email_reset_requestTracks a request to change the email address
magic_link_sign_in_requestStarts a magic link sign-in flow
magic_link_exchange_codeStores the exchange step for a magic link flow
totp_pending_authTracks a pending TOTP authentication step

Relationship Summary

  • users is the canonical identity table.
  • accounts connects a user to local or external sign-in methods.
  • sessions tracks authenticated browser or API sessions for a user.
  • verifications stores temporary records for email and multi-step auth flows.

Together, these tables cover the core Authula lifecycle: create a user, attach one or more accounts, issue sessions after sign-in, and persist temporary verification state when a workflow requires it.

On this page