This commit is contained in:
pbao9
2026-01-30 17:08:59 +07:00
parent 69923ea016
commit 72b690f22e
15 changed files with 370 additions and 211 deletions
@@ -16,7 +16,7 @@ return new class extends Migration {
$table->id()->autoIncrement();
$table->string('name', 255)->nullable();
$table->string('datacenter_id', 255)->nullable();
$table->bigInteger('vcenter_id')->default(0)->index();
$table->foreignId('vcenter_id')->constrained('module_vcenter')->cascadeOnDelete()->nullable()->index();
$table->integer('status')->default(0);
$table->timestamps();
});
@@ -18,7 +18,7 @@ return new class extends Migration
$table->string('name',100)->nullable();
$table->string('host_id',255)->nullable();
$table->string('template',255)->nullable();
$table->bigInteger('module_datacenter_id')->default(0)->index();
$table->foreignId('module_datacenter_id')->constrained('module_datacenter')->cascadeOnDelete()->nullable()->index();
$table->string('console',255)->nullable();
$table->string('iso_path',255)->nullable();
$table->timestamps();
@@ -11,10 +11,10 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('product_vm_templates', function (Blueprint $table) {
$table->foreignId('product_id')->constrained('products')->cascadeOnDelete();
$table->foreignId('vm_template_id')->constrained('vm_templates')->cascadeOnDelete();
});
// Schema::create('product_vm_templates', function (Blueprint $table) {
// $table->foreignId('product_id')->constrained('products')->cascadeOnDelete();
// $table->foreignId('vm_template_id')->constrained('vm_templates')->cascadeOnDelete();
// });
}
/**
@@ -0,0 +1,37 @@
<?php
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('module_host', function (Blueprint $table) {
$table->unsignedBigInteger('module_datacenter_id')->nullable()->change();
$table->foreign('module_datacenter_id')
->references('id')
->on('module_datacenter')
->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('module_host', function (Blueprint $table) {
// Drop the foreign key first
$table->dropForeign(['module_datacenter_id']);
// Revert column type (assuming it was bigInteger with default 0 based on previous context)
$table->bigInteger('module_datacenter_id')->default(0)->change();
});
}
};
@@ -0,0 +1,33 @@
<?php
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('module_datacenter', function (Blueprint $table) {
//
$table->unsignedBigInteger('vcenter_id')->nullable()->change();
$table->foreign('vcenter_id')
->references('id')
->on('module_vcenter')
->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('module_datacenter', function (Blueprint $table) {
//
});
}
};