MDL-75281 mod_bigbluebuttonbn: Upgrade failure when table exists

* Fix several upgrade script issue when the recording table exists or plugin has been
downgraded prior to 4.x upgrade
This commit is contained in:
Laurent David 2022-07-20 17:23:37 -04:00
parent 57c1e97bf1
commit e9844e380c

View File

@ -351,9 +351,10 @@ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) {
$field = new xmldb_field('recording', XMLDB_TYPE_TEXT, null, null, null, null, null, 'state');
// Launch rename field recording to remotedata.
$dbman->rename_field($table, $field, 'remotedata');
$field = new xmldb_field('remotedatatstamp', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'remotedata');
if ($dbman->field_exists($table, $field)) {
$dbman->rename_field($table, $field, 'remotedata');
}
$field = new xmldb_field('remotedatatstamp', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
// Conditionally launch add field remotedatatstamp.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
@ -362,8 +363,9 @@ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) {
// State is already used on remote bigbluebutton entity and has not the same semantic.
$field = new xmldb_field('state', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'imported');
// Launch rename field state to status.
$dbman->rename_field($table, $field, 'status');
if ($dbman->field_exists($table, $field)) {
$dbman->rename_field($table, $field, 'status');
}
// Bigbluebuttonbn savepoint reached.
upgrade_mod_savepoint(true, 2021072906, 'bigbluebuttonbn');
}
@ -378,8 +380,9 @@ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) {
$dbman->drop_field($table, $remotedatatstamp);
}
// Launch rename field importeddata.
$dbman->rename_field($table, $remotedata, 'importeddata');
if ($dbman->field_exists($table, $remotedata)) {
$dbman->rename_field($table, $remotedata, 'importeddata');
}
// Bigbluebuttonbn savepoint reached.
upgrade_mod_savepoint(true, 2021072907, 'bigbluebuttonbn');
}