Skip to content

Commit 50c266f

Browse files
authored
fix: fix webauthn keys (#7261)
1 parent 343495f commit 50c266f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use LaravelWebauthn\Models\WebauthnKey;
5+
6+
return new class extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
WebauthnKey::select(['id', 'credentialId'])->chunk(200, function ($keys) {
16+
foreach ($keys as $key) {
17+
$key->update(['credentialId' => $key->credentialId]);
18+
}
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
WebauthnKey::select(['id', 'credentialId'])->chunk(200, function ($keys) {
30+
foreach ($keys as $key) {
31+
$key->setRawAttributes(['credentialId' => base64_encode($key->credentialId)]);
32+
$key->save();
33+
}
34+
});
35+
}
36+
};

0 commit comments

Comments
 (0)