add db index on oauth2_access_tokens's (token_count, created_at)

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
pull/40766/head
Julien Veyssier 2023-09-01 10:34:10 +07:00
parent ddfc124767
commit e944980eb6
No known key found for this signature in database
GPG Key ID: 4141FEE162030638
1 changed files with 6 additions and 3 deletions

@ -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;