Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/lib/db/ -> install.php (source)

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

This file is executed right after the install.xml For more information, take a look to the documentation available: - Upgrade API: {@link https://moodledev.io/docs/guides/upgrade}

Copyright: 2009 Petr Skoda (http://skodak.org)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 338 lines (15 kb)
Included or required: 5 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 function


Functions that are not part of a class:

xmldb_main_install()   X-Ref
Main post-install tasks to be executed after the BD schema is available

This function is automatically executed after Moodle core DB has been
created at initial install. It's in charge of perform the initial tasks
not covered by the {@link install.xml} file, like create initial users,
roles, templates, moving stuff from other plugins...

Note that the function is only invoked once, at install time, so if new tasks
are needed in the future, they will need to be added both here (for new sites)
and in the corresponding {@link upgrade.php} file (for existing sites).

All plugins within Moodle (modules, blocks, reports...) support the existence of
their own install.php file, using the "Frankenstyle" component name as
defined at {@link https://moodledev.io/general/development/policies/codingstyle/frankenstyle}, for example:
- {@link xmldb_page_install()}. (modules don't require the plugintype ("mod_") to be used.
- {@link xmldb_enrol_meta_install()}.
- {@link xmldb_workshopform_accumulative_install()}.
- ....

Finally, note that it's also supported to have one uninstall.php file that is
executed also once, each time one plugin is uninstalled (before the DB schema is
deleted). Those uninstall files will contain one function, using the "Frankenstyle"
naming conventions, like {@link xmldb_enrol_meta_uninstall()} or {@link xmldb_workshop_uninstall()}.