aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/6.0.10_remove_restapi.php
diff options
context:
space:
mode:
authorPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
committerPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
commit4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch)
tree5c07151ae61276d334e88f6309c30d439a85c12e /db/migrations/6.0.10_remove_restapi.php
parentda0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff)
parent97a188592c679890a25c37ab78463add76a52ff7 (diff)
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'db/migrations/6.0.10_remove_restapi.php')
-rw-r--r--db/migrations/6.0.10_remove_restapi.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/db/migrations/6.0.10_remove_restapi.php b/db/migrations/6.0.10_remove_restapi.php
new file mode 100644
index 0000000..5062916
--- /dev/null
+++ b/db/migrations/6.0.10_remove_restapi.php
@@ -0,0 +1,63 @@
+<?php
+final class RemoveRestapi extends Migration
+{
+ private Migration $other_migration;
+
+ public function __construct($verbose = false)
+ {
+ parent::__construct($verbose);
+
+ require_once __DIR__ . '/1.127_setup_api.php';
+ $this->other_migration = new SetupApi($verbose);
+ }
+
+ public function description()
+ {
+ return 'Removes the deprecated REST API (essentially reverts migration 1.127)';
+ }
+
+ protected function up()
+ {
+ $this->other_migration->dropTables();
+
+ // Delete config
+ $query = "DELETE `config`, `config_values`
+ FROM `config`
+ LEFT JOIN `config_values` USING(`field`)
+ WHERE `field` IN ('API_ENABLED', 'API_OAUTH_AUTH_PLUGIN')";
+ DBManager::get()->exec($query);
+
+ // Disable all RESTAPI-Plugins
+ $query = "UPDATE `plugins`
+ SET `enabled` = 'no'
+ WHERE FIND_IN_SET('RESTAPIPlugin', `plugintype`)";
+ DBManager::get()->exec($query);
+ }
+
+ protected function down()
+ {
+ // Add config entries
+ $query = "INSERT IGNORE INTO `config`
+ (`field`, `value`, `type`, `range`, `section`,
+ `mkdate`, `chdate`, `description`)
+ VALUES (:field, :value, :type, 'global', 'global',
+ UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)";
+ $statement = DBManager::get()->prepare($query);
+
+ $statement->execute([
+ ':field' => 'API_ENABLED',
+ ':value' => 0,
+ ':type' => 'boolean',
+ ':description' => 'Schaltet die REST-API an',
+ ]);
+
+ $statement->execute([
+ ':field' => 'API_OAUTH_AUTH_PLUGIN',
+ ':value' => 'Standard',
+ ':type' => 'string',
+ ':description' => 'Definiert das für OAuth verwendete Authentifizierungsverfahren',
+ ]);
+
+ $this->other_migration->createTables();
+ }
+}