. /** * Database upgrade script * @package filter_bibleversesnwt * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Hook to upgrade database upon plugin upgrade * @param mixed $oldversion Version of plugin database before upgrade * @return bool Upgrade success status * */ function xmldb_filter_bibleversesnwt_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); if ($oldversion < 2024030800) { // Define table filter_bibleversesnwt to be created. $table = new xmldb_table('filter_bibleversesnwt'); // Adding fields to table filter_bibleversesnwt. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('book', XMLDB_TYPE_INTEGER, '5', null, null, null, null); $table->add_field('ch', XMLDB_TYPE_INTEGER, '5', null, null, null, null); $table->add_field('verse', XMLDB_TYPE_INTEGER, '5', null, null, null, null); $table->add_field('book_end', XMLDB_TYPE_INTEGER, '5', null, null, null, null); $table->add_field('ch_end', XMLDB_TYPE_INTEGER, '5', null, null, null, null); $table->add_field('verse_end', XMLDB_TYPE_INTEGER, '5', null, null, null, null); $table->add_field('content', XMLDB_TYPE_TEXT, null, null, null, null, null); // Adding keys to table filter_bibleversesnwt. $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Conditionally launch create table for filter_bibleversesnwt. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Bibleversesnwt savepoint reached. upgrade_plugin_savepoint(true, 2024030800, 'filter', 'bibleversesnwt'); } if ($oldversion < 2024030801) { // Define field time_retrieved to be added to filter_bibleversesnwt. $table = new xmldb_table('filter_bibleversesnwt'); $field = new xmldb_field('time_retrieved', XMLDB_TYPE_INTEGER, '20', null, null, null, null, 'content'); // Conditionally launch add field time_retrieved. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Bibleversesnwt savepoint reached. upgrade_plugin_savepoint(true, 2024030801, 'filter', 'bibleversesnwt'); } if ($oldversion < 2024030802) { // Define field lang to be added to filter_bibleversesnwt. $table = new xmldb_table('filter_bibleversesnwt'); $field = new xmldb_field('lang', XMLDB_TYPE_CHAR, '12', null, null, null, null, 'time_retrieved'); // Conditionally launch add field lang. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Bibleversesnwt savepoint reached. upgrade_plugin_savepoint(true, 2024030802, 'filter', 'bibleversesnwt'); } return true; }