From e944980eb65893ce0ebeeb691bee85734ef8801a Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 1 Sep 2023 10:34:10 +0200 Subject: add db index on oauth2_access_tokens's (token_count, created_at) Signed-off-by: Julien Veyssier --- apps/oauth2/lib/Migration/Version011603Date20230620111039.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/oauth2/lib/Migration/Version011603Date20230620111039.php b/apps/oauth2/lib/Migration/Version011603Date20230620111039.php index ddf2739b125..06cc4db5ab3 100644 --- a/apps/oauth2/lib/Migration/Version011603Date20230620111039.php +++ b/apps/oauth2/lib/Migration/Version011603Date20230620111039.php @@ -47,20 +47,23 @@ class Version011603Date20230620111039 extends SimpleMigrationStep { if ($schema->hasTable('oauth2_access_tokens')) { $table = $schema->getTable('oauth2_access_tokens'); $dbChanged = false; - if (!$table->hasColumn('created_at') || !$table->hasColumn('token_count')) { - $dbChanged = true; - } if (!$table->hasColumn('created_at')) { $table->addColumn('created_at', Types::BIGINT, [ 'notnull' => true, 'default' => 0, ]); + $dbChanged = true; } if (!$table->hasColumn('token_count')) { $table->addColumn('token_count', Types::BIGINT, [ 'notnull' => true, 'default' => 0, ]); + $dbChanged = true; + } + if (!$table->hasIndex('oauth2_tk_c_created_idx')) { + $table->addIndex(['token_count', 'created_at'], 'oauth2_tk_c_created_idx'); + $dbChanged = true; } if ($dbChanged) { return $schema; -- cgit v1.2.3