mirror of
https://github.com/vitodeploy/vito.git
synced 2025-05-09 01:43:35 +00:00
* SyncDatabases * Collation on Create inc WordPress * Refactored Enum * Resolve sync issue * Fix for PostgreSQL * pint * reversed enum * style adjustments * add unit tests * style * fix tests * more tests --------- Co-authored-by: Saeed Vaziry <61919774+saeedvaziry@users.noreply.github.com> Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Enums\ServerStatus;
|
|
use App\Models\Server;
|
|
use App\SSH\Services\Database\Database;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::table('databases', function (Blueprint $table) {
|
|
$table->string('collation')->nullable();
|
|
$table->string('charset')->nullable();
|
|
});
|
|
|
|
$servers = Server::query()->where('status', ServerStatus::READY)->get();
|
|
|
|
/** @var Server $server */
|
|
foreach ($servers as $server) {
|
|
$service = $server->database();
|
|
|
|
if (! $service) {
|
|
continue;
|
|
}
|
|
|
|
/** @var Database $db */
|
|
$db = $service->handler();
|
|
|
|
$db->syncDatabases(false);
|
|
$db->updateCharsets();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::table('databases', function (Blueprint $table) {
|
|
$table->dropColumn('collation');
|
|
$table->dropColumn('charset');
|
|
});
|
|
}
|
|
};
|