MDL-61255 message_popup: add table to store notifications

This commit is contained in:
Mark Nelson 2018-03-29 15:04:00 +08:00
parent 7022b8d9e4
commit 1f64f17429
3 changed files with 32 additions and 1 deletions

View File

@ -18,5 +18,15 @@
<INDEX NAME="isread" UNIQUE="false" FIELDS="isread"/>
</INDEXES>
</TABLE>
<TABLE NAME="message_popup_notifications" COMMENT="List of notifications to display in the message output popup">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="notificationid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="notificationid" TYPE="foreign" FIELDS="notificationid" REFTABLE="notifications" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>

View File

@ -83,5 +83,26 @@ function xmldb_message_popup_upgrade($oldversion) {
// Automatically generated Moodle v3.4.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2018032800) {
// Define table message_popup_notifications to be created.
$table = new xmldb_table('message_popup_notifications');
// Adding fields to table message_popup_notifications.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('notificationid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table message_popup_notifications.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('notificationid', XMLDB_KEY_FOREIGN, array('notificationid'), 'notifications', array('id'));
// Conditionally launch create table for message_popup_notifications.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Popup savepoint reached.
upgrade_plugin_savepoint(true, 2018032800, 'message', 'popup');
}
return true;
}

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018022000; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018032800; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2017110800; // Requires this Moodle version
$plugin->component = 'message_popup'; // Full name of the plugin (used for diagnostics)