diff --git a/install/install.sql b/install/install.sql index 5282c685..66fe0d65 100644 --- a/install/install.sql +++ b/install/install.sql @@ -1,4 +1,4 @@ -- Migrate from plugin version 2, if any UPDATE plugins SET enabled = 'no' WHERE pluginclassname = 'OpenCast'; -INSERT IGNORE INTO schema_version (domain, branch, version) SELECT 'OpencastV3' as domain, branch, version FROM schema_version WHERE domain = 'OpenCast'; -UPDATE schema_version SET version = 0 WHERE domain = 'OpenCast'; +REPLACE INTO schema_version (domain, branch, version) SELECT 'OpencastV3' as domain, branch, version FROM schema_version WHERE domain = 'OpenCast'; + diff --git a/migrations/096_fix_v3.php b/migrations/096_fix_v3.php index 46871051..8ebe96c2 100644 --- a/migrations/096_fix_v3.php +++ b/migrations/096_fix_v3.php @@ -24,7 +24,9 @@ public function up() // fix tool activations and plugin activations $old_plugin_id = $db->query("SELECT pluginid FROM plugins WHERE pluginclassname = 'OpenCast'")->fetchColumn(); - $new_plugin_id = $db->query("SELECT pluginid FROM plugins WHERE pluginclassname = 'OpencastV3'")->fetchColumn(); + + // guess new plugin id + $new_plugin_id = $db->query("SELECT MAX(pluginid) FROM plugins")->fetchColumn() + 1; if (!empty($old_plugin_id) && !empty($new_plugin_id)) { $stmt = $db->prepare("UPDATE tools_activated SET plugin_id = ':new' WHERE plugin_id = ':old'"); @@ -40,10 +42,12 @@ public function up() ]); } - // clear cache for autoloader classes + // Clear the whole Stud.IP cache to make the plugin work correctlu $cache = StudipCacheFactory::getCache(); - $cache_key = 'STUDIP#autoloader-classes'; - $cache->expire($cache_key); + $cache->flush(); + + // disable migrations for old plugin to prevent accidential deletion of oc-data + $db->exec("DELETE FROM schema_version WHERE domain = 'OpenCast'"); } public function down()