1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 02:22:36 +01:00

database: add migration for new mail config keys

This commit is contained in:
Matthew Penner 2022-12-12 15:12:03 -07:00
parent 24e1c56378
commit 0751eeec97
No known key found for this signature in database

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::transaction(function () {
DB::statement('UPDATE settings SET `key` = \'mail:mailers:smtp:host\' WHERE `key` = \'mail:host\' AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = \'mail:mailers:smtp:host\')');
DB::statement('UPDATE settings SET `key` = \'mail:mailers:smtp:port\' WHERE `key` = \'mail:port\' AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = \'mail:mailers:smtp:port\')');
DB::statement('UPDATE settings SET `key` = \'mail:mailers:smtp:encryption\' WHERE `key` = \'mail:encryption\' AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = \'mail:mailers:smtp:encryption\')');
DB::statement('UPDATE settings SET `key` = \'mail:mailers:smtp:username\' WHERE `key` = \'mail:username\' AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = \'mail:mailers:smtp:username\')');
DB::statement('UPDATE settings SET `key` = \'mail:mailers:smtp:password\' WHERE `key` = \'mail:password\' AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = \'mail:mailers:smtp:password\')');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
DB::transaction(function () {
DB::statement('DELETE FROM settings WHERE `key` IN (\'mail:host\', \'mail:port\', \'mail:encryption\', \'mail:username\', \'mail:password\')');
DB::statement('UPDATE settings SET `key` = \'mail:host\' WHERE `key` = \'mail:mailers:smtp:host\'');
DB::statement('UPDATE settings SET `key` = \'mail:port\' WHERE `key` = \'mail:mailers:smtp:port\'');
DB::statement('UPDATE settings SET `key` = \'mail:encryption\' WHERE `key` = \'mail:mailers:smtp:encryption\'');
DB::statement('UPDATE settings SET `key` = \'mail:username\' WHERE `key` = \'mail:mailers:smtp:username\'');
DB::statement('UPDATE settings SET `key` = \'mail:password\' WHERE `key` = \'mail:mailers:smtp:password\'');
});
}
};