-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
Harish Dhanraj Sugandhi edited this page Mar 4, 2026
·
1 revision
OpenWP creates 5 custom tables with the {prefix}_openwp_ prefix. Tables are managed via dbDelta in inc/Database/Migrations.php.
- Current schema version:
OPENWP_DB_VERSION='1.0.0' - Stored version:
OPENWP_OPTION_DB_VERSIONoption -
Migrations::maybe_upgrade()runs on everyplugins_loadedand compares versions - Self-healing:
Tables::exists()triggersmaybe_upgrade()if a table is missing
Migrations::activate()
├── create_tables() → dbDelta for all 5 tables
├── seed_options() → Default settings, policies, rate limits, MCP config
└── update_option() → Store current DB version
Stores every action execution result.
| Column | Type | Description |
|---|---|---|
id |
bigint(20) unsigned |
Auto-increment PK |
user_id |
bigint(20) unsigned |
Requesting user |
approver_id |
bigint(20) unsigned |
Approving user (0 if none) |
action_key |
varchar(191) |
Action identifier |
risk_level |
varchar(20) |
low, medium, high, critical |
prompt |
longtext |
Original user prompt |
model_output |
longtext |
Full LLM response (JSON) |
params |
longtext |
Validated action parameters (JSON) |
result |
longtext |
Action execution result (JSON) |
status |
varchar(30) |
success, failed, pending_approval, failed_backup_gate |
error_message |
longtext |
Error details if failed |
rollback_snapshot |
longtext |
Pre-action state for rollback (JSON) |
backup_id |
bigint(20) unsigned |
Associated backup (0 if none) |
created_at |
datetime |
Timestamp |
Indexes: action_key, status, created_at
Queues actions that require human approval before execution.
| Column | Type | Description |
|---|---|---|
id |
bigint(20) unsigned |
Auto-increment PK |
requester_user_id |
bigint(20) unsigned |
Who requested |
approver_user_id |
bigint(20) unsigned |
Who approved/rejected |
action_key |
varchar(191) |
Action identifier |
risk_level |
varchar(20) |
Risk classification |
prompt |
longtext |
Original prompt |
model_output |
longtext |
LLM response (JSON) |
params |
longtext |
Action parameters (JSON) |
status |
varchar(30) |
pending, approved, rejected |
decision_note |
text |
Approver's note |
typed_confirmation |
varchar(255) |
"APPROVE" for critical actions |
backup_required |
tinyint(1) |
Whether backup needed |
backup_id |
bigint(20) unsigned |
Associated backup |
execution_log_id |
bigint(20) unsigned |
Log entry after execution |
created_at |
datetime |
Request timestamp |
decided_at |
datetime |
Decision timestamp |
Indexes: action_key, status, created_at
Persistent memory for the AI agent (preferences, constraints, facts, workflows).
| Column | Type | Description |
|---|---|---|
id |
bigint(20) unsigned |
Auto-increment PK |
memory_type |
varchar(40) |
preference, constraint, fact, workflow |
memory_key |
varchar(191) |
Unique key within type |
memory_value |
longtext |
Stored value |
updated_at |
datetime |
Last update |
Indexes: UNIQUE(memory_type, memory_key)
Full SQL database dumps created before high-risk actions.
| Column | Type | Description |
|---|---|---|
id |
bigint(20) unsigned |
Auto-increment PK |
user_id |
bigint(20) unsigned |
Who triggered backup |
file_path |
text |
Path to .sql.gz file |
file_size |
bigint(20) unsigned |
Size in bytes |
checksum |
varchar(128) |
SHA-256 hash for integrity |
status |
varchar(30) |
completed, failed |
meta |
longtext |
Metadata (JSON: reason, engine, version) |
expires_at |
datetime |
Auto-cleanup date |
created_at |
datetime |
Creation timestamp |
Indexes: status, created_at
Tracks daily usage per user for rate limiting.
| Column | Type | Description |
|---|---|---|
id |
bigint(20) unsigned |
Auto-increment PK |
usage_day |
date |
Calendar date |
user_id |
bigint(20) unsigned |
User ID |
actions_count |
int(11) |
Actions executed today |
tokens_in |
int(11) |
Input tokens consumed |
tokens_out |
int(11) |
Output tokens consumed |
last_action_at |
datetime |
Last action timestamp |
updated_at |
datetime |
Last update |
Indexes: UNIQUE(usage_day, user_id), user_id
On activation, these options are created with defaults if they don't exist:
| Option | Default |
|---|---|
openwp_settings |
See Settings & Configuration |
openwp_action_policies |
[] (empty) |
openwp_rate_limits |
50/user, 500/site, 120K tokens/user, 1.2M tokens/site |
openwp_mcp_enabled |
false |
openwp_mcp_debug_mode |
false |
openwp_mcp_modules |
All 6 modules enabled |
openwp_mcp_bearer_token |
'' (empty) |
OpenWP v0.1.4 | GitHub Repository | GPLv2+