diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-09-13 13:07:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 13:07:37 +0200 |
commit | 0dcc5c0e9f346912ed8c263950ad91f35a41bff8 (patch) | |
tree | c360c1c57b53a007ffec586428901ad1669b2dad /core | |
parent | d31456093d3bb2ff55fe0fde07050f07301459d6 (diff) | |
parent | 474a5b55d39e621c12947b50ea6c8febfceed7d7 (diff) | |
download | nextcloud-server-0dcc5c0e9f346912ed8c263950ad91f35a41bff8.tar.gz nextcloud-server-0dcc5c0e9f346912ed8c263950ad91f35a41bff8.zip |
Merge pull request #28728 from nextcloud/add-database-backend-limiter
Add database ratelimiting backend
Diffstat (limited to 'core')
-rw-r--r-- | core/Migrations/Version23000Date20210906132259.php | 44 |
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; + } +} |