Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2021-09-13 19:07:32 +0300
committerGitHub <noreply@github.com>2021-09-13 19:07:32 +0300
commit7997483484921004bf3f7c23844db89a0c7d03b6 (patch)
treef4e9151e15c15279a6465e8e18f17d307ce3081f /core
parent7025c055e5110d46eaa00d06be378b721412744b (diff)
parentf416cacc64f26b88181ae6542e92ed1e5621ccd7 (diff)
Merge pull request #28815 from nextcloud/backport/28728/stable21
[stable21] Add database ratelimiting backend
Diffstat (limited to 'core')
-rw-r--r--core/Migrations/Version23000Date20210906132259.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/core/Migrations/Version23000Date20210906132259.php b/core/Migrations/Version23000Date20210906132259.php
new file mode 100644
index 00000000000..26d18edc8f1
--- /dev/null
+++ b/core/Migrations/Version23000Date20210906132259.php
@@ -0,0 +1,44 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OC\Core\Migrations;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version23000Date20210906132259 extends SimpleMigrationStep {
+ private const TABLE_NAME = 'ratelimit_entries';
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $hasTable = $schema->hasTable(self::TABLE_NAME);
+
+ if (!$hasTable) {
+ $table = $schema->createTable(self::TABLE_NAME);
+ $table->addColumn('hash', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 128,
+ ]);
+ $table->addColumn('delete_after', Types::DATETIME, [
+ 'notnull' => true,
+ ]);
+ $table->addIndex(['hash'], 'ratelimit_hash');
+ $table->addIndex(['delete_after'], 'ratelimit_delete_after');
+ return $schema;
+ }
+
+ return null;
+ }
+}