Skip to content

Commit

Permalink
ref(backend): Remove ApiToken generation from migration
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Aug 22, 2023
1 parent 3c7a858 commit 495cd07
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions config/Migrations/20230821152146_AddApiToken.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?php
declare(strict_types=1);

use App\Model\Entity\User;
use Cake\ORM\Locator\LocatorAwareTrait;
use Migrations\AbstractMigration;

use function Sentry\captureException;

class AddApiToken extends AbstractMigration
{
use LocatorAwareTrait;
Expand Down Expand Up @@ -42,25 +39,6 @@ public function up(): void
'null' => true,
])
->create();

$usersTable = $this->fetchTable('Users');
$apiTokensTable = $this->fetchTable('ApiTokens');

$users = $usersTable->find()
->where([
'Users.slack_is_bot' => false,
'Users.status' => User::STATUS_ACTIVE,
'Users.role !=' => User::ROLE_SERVICE,
])
->all();

foreach ($users as $user) {
try {
$apiTokensTable->generateApiToken($user);
} catch (Throwable $e) {
captureException($e);
}
}
}

/**
Expand Down

0 comments on commit 495cd07

Please sign in to comment.