Schema Definition for Rebackk's Pocketbase Adapter
A detailed explanation of the schema used in Rebackk's Pocketbase Adapter.
Schema Definition
The schema used in Rebackk's Pocketbase Adapter is a set of collections that are used to store user data, session data, and other information required for authentication.
Collections
The schema includes the following collections:
- Users: Custom PocketBase users collection for NextAuth.js.
- Accounts: For linking users with their OAuth or credentials accounts.
- Sessions: To manage user sessions and tokens.
- Authenticators: To handle multi-factor authentication (MFA) flows.
- VerificationTokens: For managing email verification flows and password resets.
Accounts Collection
- Collection ID:
accounts_collection
- Name:
accounts
- Type:
base
- System: No
- Schema Fields:
account_user_id
:- Type:
relation
- Required: Yes
- Relation to:
users_collection
- Type:
account_type
:- Type:
text
- Required: Yes
- Min Length: 3
- Max Length: 50
- Type:
account_provider
:- Type:
text
- Required: Yes
- Min Length: 3
- Max Length: 50
- Type:
account_provider_account_id
:- Type:
text
- Required: Yes
- Min Length: 5
- Max Length: 255
- Type:
- Indexes:
idx_provider_provider_account_id
: A unique index on the fieldsaccount_provider
andaccount_provider_account_id
.
Show JSON
{
"collection_id": "accounts_collection",
"name": "accounts",
"type": "base",
"system": false,
"schema_fields": [
{
"name": "account_user_id",
"type": "relation",
"required": true,
"relation_to": "users_collection"
},
{
"name": "account_type",
"type": "text",
"required": true,
"min_length": 3,
"max_length": 50
},
{
"name": "account_provider",
"type": "text",
"required": true,
"min_length": 3,
"max_length": 50
},
{
"name": "account_provider_account_id",
"type": "text",
"required": true,
"min_length": 5,
"max_length": 255
}
],
"indexes": [
{
"name": "idx_provider_provider_account_id",
"unique": true,
"fields": ["account_provider", "account_provider_account_id"]
}
]
}
Authenticators Collection
- Collection ID:
authenticators_collection
- Name:
authenticators
- Type:
base
- System: No
- Schema Fields:
authenticator_credential_id
:- Type:
text
- Required: Yes
- Unique: Yes
- Min Length: 5
- Max Length: 255
- Type:
authenticator_user_id
:- Type:
relation
- Required: Yes
- Relation to:
users_collection
- Type:
authenticator_provider_account_id
:- Type:
text
- Required: Yes
- Min Length: 5
- Max Length: 255
- Type:
authenticator_credential_public_key
:- Type:
text
- Required: Yes
- Type:
authenticator_counter
:- Type:
number
- Required: Yes
- Type:
authenticator_credential_device_type
:- Type:
text
- Required: Yes
- Min Length: 3
- Max Length: 50
- Type:
authenticator_credential_backed_up
:- Type:
bool
- Required: Yes
- Type:
authenticator_transports
:- Type:
text
- Required: No
- Type:
- Indexes:
idx_user_credential_id
: A unique index on the fieldsauthenticator_user_id
andauthenticator_credential_id
.
Show JSON
{
"collection_id": "authenticators_collection",
"name": "authenticators",
"type": "base",
"system": false,
"schema_fields": [
{
"name": "authenticator_credential_id",
"type": "text",
"required": true,
"unique": true,
"min_length": 5,
"max_length": 255
},
{
"name": "authenticator_user_id",
"type": "relation",
"required": true,
"relation_to": "users_collection"
},
{
"name": "authenticator_provider_account_id",
"type": "text",
"required": true,
"min_length": 5,
"max_length": 255
},
{
"name": "authenticator_credential_public_key",
"type": "text",
"required": true
},
{
"name": "authenticator_counter",
"type": "number",
"required": true
},
{
"name": "authenticator_credential_device_type",
"type": "text",
"required": true,
"min_length": 3,
"max_length": 50
},
{
"name": "authenticator_credential_backed_up",
"type": "bool",
"required": true
},
{
"name": "authenticator_transports",
"type": "text",
"required": false
}
],
"indexes": [
{
"name": "idx_user_credential_id",
"unique": true,
"fields": ["authenticator_user_id", "authenticator_credential_id"]
}
]
}
Sessions Collection
- Collection ID:
sessions_collection
- Name:
sessions
- Type:
base
- System: No
- Schema Fields:
session_session_token
:- Type:
text
- Required: Yes
- Unique: Yes
- Min Length: 10
- Max Length: 255
- Type:
session_user_id
:- Type:
relation
- Required: Yes
- Relation to:
users_collection
- Type:
session_expires
:- Type:
date
- Required: Yes
- Type:
- Indexes: None
Show JSON
{
"collection_id": "sessions_collection",
"name": "sessions",
"type": "base",
"system": false,
"schema_fields": [
{
"name": "session_session_token",
"type": "text",
"required": true,
"unique": true,
"min_length": 10,
"max_length": 255
},
{
"name": "session_user_id",
"type": "relation",
"required": true,
"relation_to": "users_collection"
},
{
"name": "session_expires",
"type": "date",
"required": true
}
]
}
Users Collection
- Collection ID:
users_collection
- Name:
users
- Type:
base
- System: No
- Schema Fields:
user_name
:- Type:
text
- Required: Yes
- Min Length: 5
- Max Length: 255
- Type:
user_email
:- Type:
email
- Required: Yes
- Unique: Yes
- Type:
user_email_verified
:- Type:
date
- Required: No
- Type:
user_image
:- Type:
text
- Required: No
- Type:
Show JSON
{
"collection_id": "users_collection",
"name": "users",
"type": "base",
"system": false,
"schema_fields": [
{
"name": "user_name",
"type": "text",
"required": true,
"min_length": 5,
"max_length": 255
},
{
"name": "user_email",
"type": "email",
"required": true,
"unique": true
},
{
"name": "user_email_verified",
"type": "date",
"required": false
},
{
"name": "user_image",
"type": "text",
"required": false
}
]
}
Verification Tokens Collection
- Collection ID:
verification_tokens_collection
- Name:
verification_tokens
- Type:
base
- System: No
- Schema Fields:
verification_identifier
:- Type:
text
- Required: Yes
- Min Length: 5
- Max Length: 255
- Type:
verification_token
:- Type:
text
- Required: Yes
- Min Length: 10
- Max Length: 255
- Type:
verification_expires
:- Type:
date
- Required: Yes
- Type:
- Indexes:
idx_identifier_token
: A unique index on the fieldsverification_identifier
andverification_token
.
Show JSON
{
"collection_id": "verification_tokens_collection",
"name": "verification_tokens",
"type": "base",
"system": false,
"schema_fields": [
{
"name": "verification_identifier",
"type": "text",
"required": true,
"min_length": 5,
"max_length": 255
},
{
"name": "verification_token",
"type": "text",
"required": true,
"min_length": 10,
"max_length": 255
},
{
"name": "verification_expires",
"type": "date",
"required": true
}
],
"indexes": [
{
"name": "idx_identifier_token",
"unique": true,
"fields": ["verification_identifier", "verification_token"]
}
]
}
Notes:
- All collections are defined as
base
types and are not system-level. - Relations are established to the
users_collection
. - Indexes are in place for ensuring uniqueness for specific fields in collections such as
authenticators
,accounts
, andverification_tokens
.