Verify your Moodle Database Schema
There is a very handy CLI tool admin/cli/check_database_schema.php
which compares the structure of your Moodle database against the XMLDB
metadata in the code and looks for any issues.
These might includes issues such as:
- Missing tables – they exist in XMLDB but not in your DB (not good!)
- Unexpected tables – tables in your database not defined in XMLDB (e.g. created outside of Moodle)
- Mismatches between table column definitions in the database and XMLDB
Some things may be acceptable to ignore, but it pays to do a check, particularly after an upgrade to make sure the upgrade process worked correctly and that you aren’t missing any core or plugin database tables that are defined in XMLDB, as these will pop up as database errors in your application sooner or later (e.g. Error reading from database
).
If you need to build any missing core tables, remember they are defined under:
From here find lib/db
(core database tables) and choose Load
, followed by Edit
. Find the table you need and choose Edit
. You can then use View SQL code to get the relevant SQL commands to create the table if it is missing from your database.
No Comments