From 6bb88b0306af8691ae7e4f6545b9e9ebd0520acf Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Sat, 27 Apr 2019 16:08:43 +0200 Subject: change ref field name in variable table --- db/upgrade.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'db/upgrade.php') diff --git a/db/upgrade.php b/db/upgrade.php index 48cc159..f1db600 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -80,6 +80,48 @@ function xmldb_qtype_algebra_upgrade($oldversion=0) { } upgrade_plugin_savepoint(true, 2012061702, 'qtype', 'algebra'); } + + if ($oldversion < 2019042705) { + + // Define key question (foreign) to be dropped form qtype_algebra_variables. + $table = new xmldb_table('qtype_algebra_variables'); + $key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id')); + + // Launch drop key question. + $dbman->drop_key($table, $key); + + // Record that qtype_algebra savepoint was reached. + upgrade_plugin_savepoint(true, 2019042705, 'qtype', 'algebra'); + } + + if ($oldversion < 2019042706) { + + // Rename field question on table qtype_algebra_variables to questionid. + $table = new xmldb_table('qtype_algebra_variables'); + $field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id'); + + // Launch rename field question. + if ($dbman->field_exists($table, $field)) { + $dbman->rename_field($table, $field, 'questionid'); + } + + // Record that qtype_algebra savepoint was reached. + upgrade_plugin_savepoint(true, 2019042706, 'qtype', 'algebra'); + } + + if ($oldversion < 2019042707) { + + // Define key questionid (foreign-unique) to be added to qtype_algebra_variables. + $table = new xmldb_table('qtype_algebra_variables'); + $key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id')); + + // Launch add key questionid. + $dbman->add_key($table, $key); + + // Record that qtype_algebra savepoint was reached. + upgrade_plugin_savepoint(true, 2019042707, 'qtype', 'algebra'); + } + return true; } -- cgit v1.2.3