You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version23000Date20210906132259.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. namespace OC\Core\Migrations;
  4. use Closure;
  5. use OCP\DB\ISchemaWrapper;
  6. use OCP\DB\Types;
  7. use OCP\Migration\IOutput;
  8. use OCP\Migration\SimpleMigrationStep;
  9. class Version23000Date20210906132259 extends SimpleMigrationStep {
  10. private const TABLE_NAME = 'ratelimit_entries';
  11. /**
  12. * @param IOutput $output
  13. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  14. * @param array $options
  15. * @return null|ISchemaWrapper
  16. */
  17. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  18. /** @var ISchemaWrapper $schema */
  19. $schema = $schemaClosure();
  20. $hasTable = $schema->hasTable(self::TABLE_NAME);
  21. if (!$hasTable) {
  22. $table = $schema->createTable(self::TABLE_NAME);
  23. $table->addColumn('hash', Types::STRING, [
  24. 'notnull' => true,
  25. 'length' => 128,
  26. ]);
  27. $table->addColumn('delete_after', Types::DATETIME, [
  28. 'notnull' => true,
  29. ]);
  30. $table->addIndex(['hash'], 'ratelimit_hash');
  31. $table->addIndex(['delete_after'], 'ratelimit_delete_after');
  32. return $schema;
  33. }
  34. return null;
  35. }
  36. }