diff options
author | Jean-Michel Vedrine <vedrine@vedrine.org> | 2019-04-27 16:08:43 +0200 |
---|---|---|
committer | Jean-Michel Vedrine <vedrine@vedrine.org> | 2019-04-27 16:08:43 +0200 |
commit | 6bb88b0306af8691ae7e4f6545b9e9ebd0520acf (patch) | |
tree | 674dae06150e515c360d4e5e14d2f0a5f1ed1021 /db/upgrade.php | |
parent | 7f141a597f4367c03edc141578a67f3706cb0f9b (diff) |
change ref field name in variable table
Diffstat (limited to 'db/upgrade.php')
-rw-r--r-- | db/upgrade.php | 42 |
1 files changed, 42 insertions, 0 deletions
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; } |