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:

  1. Users: Custom PocketBase users collection for NextAuth.js.
  2. Accounts: For linking users with their OAuth or credentials accounts.
  3. Sessions: To manage user sessions and tokens.
  4. Authenticators: To handle multi-factor authentication (MFA) flows.
  5. 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
    • account_type:
      • Type: text
      • Required: Yes
      • Min Length: 3
      • Max Length: 50
    • account_provider:
      • Type: text
      • Required: Yes
      • Min Length: 3
      • Max Length: 50
    • account_provider_account_id:
      • Type: text
      • Required: Yes
      • Min Length: 5
      • Max Length: 255
  • Indexes:
    • idx_provider_provider_account_id: A unique index on the fields account_provider and account_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
    • authenticator_user_id:
      • Type: relation
      • Required: Yes
      • Relation to: users_collection
    • authenticator_provider_account_id:
      • Type: text
      • Required: Yes
      • Min Length: 5
      • Max Length: 255
    • authenticator_credential_public_key:
      • Type: text
      • Required: Yes
    • authenticator_counter:
      • Type: number
      • Required: Yes
    • authenticator_credential_device_type:
      • Type: text
      • Required: Yes
      • Min Length: 3
      • Max Length: 50
    • authenticator_credential_backed_up:
      • Type: bool
      • Required: Yes
    • authenticator_transports:
      • Type: text
      • Required: No
  • Indexes:
    • idx_user_credential_id: A unique index on the fields authenticator_user_id and authenticator_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
    • session_user_id:
      • Type: relation
      • Required: Yes
      • Relation to: users_collection
    • session_expires:
      • Type: date
      • Required: Yes
  • 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
    • user_email:
      • Type: email
      • Required: Yes
      • Unique: Yes
    • user_email_verified:
      • Type: date
      • Required: No
    • user_image:
      • Type: text
      • Required: No
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
    • verification_token:
      • Type: text
      • Required: Yes
      • Min Length: 10
      • Max Length: 255
    • verification_expires:
      • Type: date
      • Required: Yes
  • Indexes:
    • idx_identifier_token: A unique index on the fields verification_identifier and verification_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, and verification_tokens.