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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: migrate to new encryption options
peaklabs-deva18c2e0f55d8
diff --git a/database/migrations/2024_12_23_142402_update_email_encryption_values.php b/database/migrations/2024_12_23_142402_update_email_encryption_values.phpnew file mode 100644index 0000000000..c21c910d16--- /dev/null+++ b/database/migrations/2024_12_23_142402_update_email_encryption_values.php@@ -0,0 +1,130 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Support\Facades\DB;++class UpdateEmailEncryptionValues extends Migration+{+ /**+ * The encryption mappings.+ */+ private array $encryptionMappings = [+ 'tls' => 'starttls',+ 'ssl' => 'tls',+ '' => 'none',+ ];++ /**+ * Run the migrations.+ */+ public function up(): void+ {+ try {+ DB::beginTransaction();++ $instanceSettings = DB::table('instance_settings')->get();+ foreach ($instanceSettings as $setting) {+ try {+ if (array_key_exists($setting->smtp_encryption, $this->encryptionMappings)) {+ DB::table('instance_settings')+ ->where('id', $setting->id)+ ->update([+ 'smtp_encryption' => $this->encryptionMappings[$setting->smtp_encryption],+ ]);+ }+ } catch (\Exception $e) {+ \Log::error('Failed to update instance_settings encryption for ID: '.$setting->id, [+ 'error' => $e->getMessage(),+ 'old_value' => $setting->smtp_encryption,+ ]);+ }+ }++ $emailSettings = DB::table('email_notification_settings')->get();+ foreach ($emailSettings as $setting) {+ try {+ if (array_key_exists($setting->smtp_encryption, $this->encryptionMappings)) {+ DB::table('email_notification_settings')+ ->where('id', $setting->id)+ ->update([+ 'smtp_encryption' => $this->encryptionMappings[$setting->smtp_encryption],+ ]);+ }+ } catch (\Exception $e) {+ \Log::error('Failed to update email_notification_settings encryption for ID: '.$setting->id, [+ 'error' => $e->getMessage(),+ 'old_value' => $setting->smtp_encryption,+ ]);+ }+ }++ DB::commit();+ } catch (\Exception $e) {+ DB::rollBack();+ \Log::error('Failed to complete email encryption migration', [+ 'error' => $e->getMessage(),+ ]);+ throw $e;+ }+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ try {+ DB::beginTransaction();++ $reverseMapping = [+ 'starttls' => 'tls',+ 'tls' => 'ssl',+ 'none' => '',+ ];++ $instanceSettings = DB::table('instance_settings')->get();+ foreach ($instanceSettings as $setting) {+ try {+ if (array_key_exists($setting->smtp_encryption, $reverseMapping)) {+ DB::table('instance_settings')+ ->where('id', $setting->id)+ ->update([+ 'smtp_encryption' => $reverseMapping[$setting->smtp_encryption],+ ]);+ }+ } catch (\Exception $e) {+ \Log::error('Failed to reverse instance_settings encryption for ID: '.$setting->id, [+ 'error' => $e->getMessage(),+ 'old_value' => $setting->smtp_encryption,+ ]);+ }+ }++ $emailSettings = DB::table('email_notification_settings')->get();+ foreach ($emailSettings as $setting) {+ try {+ if (array_key_exists($setting->smtp_encryption, $reverseMapping)) {+ DB::table('email_notification_settings')+ ->where('id', $setting->id)+ ->update([+ 'smtp_encryption' => $reverseMapping[$setting->smtp_encryption],+ ]);+ }+ } catch (\Exception $e) {+ \Log::error('Failed to reverse email_notification_settings encryption for ID: '.$setting->id, [+ 'error' => $e->getMessage(),+ 'old_value' => $setting->smtp_encryption,+ ]);+ }+ }++ DB::commit();+ } catch (\Exception $e) {+ DB::rollBack();+ \Log::error('Failed to complete email encryption rollback migration', [+ 'error' => $e->getMessage(),+ ]);+ throw $e;+ }+ }+}