Enhance VM service management: add service_id and plain_password fields, sync service records, and update related migrations
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('module_vmware', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('module_vmware', 'service_id')) {
|
||||
$table->unsignedBigInteger('service_id')->nullable()->index()->after('id');
|
||||
$table->foreign('service_id')
|
||||
->references('id')
|
||||
->on('services')
|
||||
->cascadeOnDelete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_vmware', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('module_vmware', 'service_id')) {
|
||||
$table->dropForeign(['service_id']);
|
||||
$table->dropColumn('service_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('module_vmware', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('module_vmware', 'plain_password')) {
|
||||
$table->text('plain_password')->nullable()->after('password')
|
||||
->comment('Plaintext VM password — shown to customer on service detail');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_vmware', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('module_vmware', 'plain_password')) {
|
||||
$table->dropColumn('plain_password');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
// Step 1: drop the old string column (loses legacy vmware_id string values)
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->dropColumn('vm_id');
|
||||
});
|
||||
|
||||
// Step 2: add as proper integer FK → module_vmware.id
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('vm_id')->nullable()->index()->after('invoice_id')
|
||||
->comment('FK → module_vmware.id (set after VM provisioning completes)');
|
||||
|
||||
$table->foreign('vm_id')
|
||||
->references('id')
|
||||
->on('module_vmware')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->dropForeign(['vm_id']);
|
||||
$table->dropColumn('vm_id');
|
||||
});
|
||||
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->string('vm_id')->nullable()->index()->after('invoice_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user