better-auth core が管理するユーザー認証関連の4テーブルです。
ユーザーの基本情報を保持するテーブルです。better-auth の各プラグインがカラムを追加しています。
| カラム | 型 | NULL | デフォルト | 説明 | プラグイン |
|---|
id | text | NO | — | 主キー | core |
name | text | NO | — | 表示名 | core |
email | text | NO | — | メールアドレス(ユニーク) | core |
emailVerified | boolean | NO | false | メール確認済み | core |
image | text | YES | — | プロフィール画像 URL | core |
role | text | YES | — | システムロール | admin |
banned | boolean | YES | false | BAN 状態 | admin |
banReason | text | YES | — | BAN 理由 | admin |
banExpires | timestamptz(3) | YES | — | BAN 期限 | admin |
phoneNumber | text | YES | — | 電話番号(ユニーク) | phoneNumber |
phoneNumberVerified | boolean | YES | false | 電話番号確認済み | phoneNumber |
username | text | YES | — | ユーザー名(ユニーク) | username |
displayUsername | text | YES | — | 表示用ユーザー名 | username |
isAnonymous | boolean | YES | false | 匿名ユーザーフラグ | anonymous |
createdAt | timestamptz(3) | NO | NOW() | 作成日時 | core |
updatedAt | timestamptz(3) | NO | NOW() | 更新日時 | core |
注意: email には内部用のユニークメール(XXXX.plfumg.com)が格納されます。ユーザーが入力した実際のメールアドレスは outerMail テーブルに保持されます。
ユーザーセッションを管理するテーブルです。
| カラム | 型 | NULL | デフォルト | 説明 | プラグイン |
|---|
id | text | NO | — | 主キー | core |
token | text | NO | — | セッショントークン(ユニーク) | core |
expiresAt | timestamptz(3) | NO | — | 有効期限 | core |
userId | text | NO | — | ユーザー ID | core |
ipAddress | text | YES | — | IP アドレス | core |
userAgent | text | YES | — | User-Agent | core |
impersonatedBy | text | YES | — | 代理認証者 ID | admin |
activeOrganizationId | text | YES | — | アクティブ組織 ID | organization |
createdAt | timestamptz(3) | NO | NOW() | 作成日時 | core |
updatedAt | timestamptz(3) | NO | — | 更新日時 | core |
| 名前 | カラム | 種別 |
|---|
| — | token | UNIQUE |
session_userId_idx | userId | INDEX |
外部認証プロバイダーとの連携を管理するテーブルです。
| カラム | 型 | NULL | デフォルト | 説明 |
|---|
id | text | NO | — | 主キー |
accountId | text | NO | — | プロバイダー側のアカウント ID |
providerId | text | NO | — | プロバイダー識別子(‘credential’ | ‘google’ 等) |
userId | text | NO | — | ユーザー ID |
accessToken | text | YES | — | アクセストークン |
refreshToken | text | YES | — | リフレッシュトークン |
idToken | text | YES | — | ID トークン |
accessTokenExpiresAt | timestamptz(3) | YES | — | アクセストークン有効期限 |
refreshTokenExpiresAt | timestamptz(3) | YES | — | リフレッシュトークン有効期限 |
scope | text | YES | — | スコープ |
password | text | YES | — | ハッシュ化パスワード(credential の場合) |
createdAt | timestamptz(3) | NO | NOW() | 作成日時 |
updatedAt | timestamptz(3) | NO | — | 更新日時 |
| 名前 | カラム | 種別 |
|---|
account_userId_idx | userId | INDEX |
| providerId | 説明 |
|---|
credential | メール/パスワード認証 |
google | Google OAuth |
anonymous | 匿名認証 |
メール確認・パスワードリセット等の認証トークンを管理するテーブルです。
| カラム | 型 | NULL | デフォルト | 説明 |
|---|
id | text | NO | — | 主キー |
identifier | text | NO | — | 識別子(メールアドレス等) |
value | text | NO | — | トークン値 |
expiresAt | timestamptz(3) | NO | — | 有効期限 |
createdAt | timestamptz(3) | NO | NOW() | 作成日時 |
updatedAt | timestamptz(3) | NO | NOW() | 更新日時 |
| 名前 | カラム | 種別 |
|---|
verification_identifier_idx | identifier | INDEX |