From e3f677d3f9b1655537d919204d9fb848fbcc6b79 Mon Sep 17 00:00:00 2001 From: Marcus Green Date: Wed, 17 Jul 2024 13:21:14 +0100 Subject: [PATCH] Add aiconnect_queue for batch processing --- db/upgrade.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 db/upgrade.php diff --git a/db/upgrade.php b/db/upgrade.php new file mode 100644 index 0000000..7565315 --- /dev/null +++ b/db/upgrade.php @@ -0,0 +1,60 @@ +. + +/** + * Upgrade steps for AI Connect tool + * + * Documentation: {@link https://moodledev.io/docs/guides/upgrade} + * + * @package tool_aiconnect + * @category upgrade + * @copyright 2024 YOUR NAME + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Execute the plugin upgrade steps from the given old version. + * + * @param int $oldversion + * @return bool + */ +function xmldb_tool_aiconnect_upgrade($oldversion) { + global $DB; + $dbman = $DB->get_manager(); + if ($oldversion < 2024032006) { + + // Define table tool_aiconnect_queue to be created. + $table = new xmldb_table('tool_aiconnect_queue'); + + // Adding fields to table tool_aiconnect_queue. + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('prompttext', XMLDB_TYPE_TEXT, null, null, null, null, null); + $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null); + $table->add_field('inqueue', XMLDB_TYPE_INTEGER, '1', null, null, null, '1'); + + // Adding keys to table tool_aiconnect_queue. + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + + // Conditionally launch create table for tool_aiconnect_queue. + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + // Aiconnect savepoint reached. + upgrade_plugin_savepoint(true, 2024032006, 'tool', 'aiconnect'); + } + return true; +} diff --git a/version.php b/version.php index f2c2397..6822330 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'tool_aiconnect'; -$plugin->version = 2024032004; +$plugin->version = 2024032006; $plugin->requires = 2022112800; $plugin->release = '4.1.1';