mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 14:06:15 +00:00
Database collations (#489)
* 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>
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user