Data model

The tables the framework ships with and how they relate. Table names carry the app's prefix (xp_users_roles is the roles table of xp_users). Columns shown are the keys and the ones the docs talk about, not every column. How to read an ER diagram: Diagram guide.

1. Users and their roles

An account is a row in xp_users_user. A user holds a set of roles through xp_users_user_roles, never empty; a membership may carry a scope. xp_users_user.role is only a cache of the strongest role.

Where to look

  • api/apps/xp_users/xp_users.xml: the user, user_meta, roles and user_roles tables.
  • api/apps/auth/auth.xml: rememberme_tokens.
  • README "Multiple roles", "Scoped grants" and "Users inside a space".

2. What a role grants

One row per app action in xp_users_role_permissions, with a reach of global or scoped; unticking a grant sets revoked_at instead of deleting the row. xp_users_permissions is the role's legacy blob, kept in step with those rows. The session falls back to the per-user copy in xp_users_user.permissions only when none of the user's roles has a live row here.

Where to look

  • api/apps/xp_users/xp_users.xml: roles, permissions, role_permissions.
  • api/apps/xp_notification/xp_notification.xml: role_notifications.
  • README "Permissions" and "Roles".

3. Framework system tables

Tables the framework creates in the main database for its own bookkeeping. They do not reference each other.

Heartbeat

Migrations, upgrade steps and the access log

Where to look

  • api/core/heartbeat/HeartbeatDAO.class.php: system_worker and system_worker_trigger_logs.
  • api/core/Modules/Migrator/MigrationRepository.class.php: system_migrations.
  • api/core/Modules/Upgrader/UpgradeRepository.class.php: system_upgrades.
  • api/core/Modules/Loging/AccessLogDAO.class.php: access_log.

4. Local SQLite (do.db)

api/db/do.db is a SQLite file on the install itself, so it works before MySQL is configured. It holds the error log, the scheduler log and the upgrade state.

Logs

Upgrade state

Where to look

  • api/include/localdb_initialize.sql: error_log, db_info, scheduler_log.
  • api/core/Modules/Upgrader/UpgradeState.class.php: upgrade_state, upgrade_holds, upgrade_meta.
  • api/core/classes/Sqlitedb.class.php: the wrapper the error log and the scheduler log use; UpgradeState opens the file with PHP's SQLite3 directly.

5. Settings, domains and custom fields

xp_system keeps the install's options and data, custom domains with their sign-in tokens, and custom fields with the conditions and actions that drive them.

Options and data

Custom domains

Custom fields

Where to look

  • api/apps/xp_system/xp_system.xml: all seven tables.
  • api/core/Modules/CustomFields/: the module that reads the custom field tables.
  • README "Per-space settings" for how options are overridden per space on a SaaS install.