Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: migrations

Andras Bacsai68efd4b55387
diff --git a/database/migrations/2024_09_16_111428_encrypt_existing_private_keys.php b/database/migrations/2024_09_16_111428_encrypt_existing_private_keys.php
index e2297cf375..19274ad9bb 100644
--- a/database/migrations/2024_09_16_111428_encrypt_existing_private_keys.php
+++ b/database/migrations/2024_09_16_111428_encrypt_existing_private_keys.php
@@ -1,19 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
-use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Crypt;
+use Illuminate\Support\Facades\DB;
class EncryptExistingPrivateKeys extends Migration
{
public function up()
{
- DB::table('private_keys')->chunkById(100, function ($keys) {
- foreach ($keys as $key) {
- DB::table('private_keys')
- ->where('id', $key->id)
- ->update(['private_key' => Crypt::encryptString($key->private_key)]);
- }
- });
+ try {
+ DB::table('private_keys')->chunkById(100, function ($keys) {
+ foreach ($keys as $key) {
+ DB::table('private_keys')
+ ->where('id', $key->id)
+ ->update(['private_key' => Crypt::encryptString($key->private_key)]);
+ }
+ });
+ } catch (\Exception $e) {
+ echo 'Encrypting private keys failed.';
+ echo $e->getMessage();
+ }
+
}
}
diff --git a/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php b/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php
index f16eccb5c6..dfce5682a4 100644
--- a/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php
+++ b/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php
@@ -3,6 +3,7 @@
use App\Models\PrivateKey;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AddSshKeyFingerprintToPrivateKeysTable extends Migration
@@ -13,13 +14,20 @@ class AddSshKeyFingerprintToPrivateKeysTable extends Migration
$table->string('fingerprint')->after('private_key')->nullable();
});
- PrivateKey::whereNull('fingerprint')->each(function ($key) {
- $fingerprint = PrivateKey::generateFingerprint($key->private_key);
- if ($fingerprint) {
- $key->fingerprint = $fingerprint;
- $key->save();
- }
- });
+ try {
+ DB::table('private_keys')->chunkById(100, function ($keys) {
+ foreach ($keys as $key) {
+ $fingerprint = PrivateKey::generateFingerprint($key->private_key);
+ if ($fingerprint) {
+ $key->fingerprint = $fingerprint;
+ $key->save();
+ }
+ }
+ });
+ } catch (\Exception $e) {
+ echo 'Generating fingerprints failed.';
+ echo $e->getMessage();
+ }
}
public function down()