Files
portal-api/database/migrations/2026_03_12_100435_module_snapshot.php

72 lines
2.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('module_snapshot', function (Blueprint $table) {
$table->id();
$table->string('name', 255)->nullable();
$table->unsignedBigInteger('customer_id')->nullable()->index();
$table->unsignedBigInteger('module_vmware_id')->nullable()->index();
$table->text('description')->nullable();
// Async snapshot status
$table->enum('status', [
'pending',
'processing',
'success',
'failed'
])->default('pending')->index();
// vCenter mapping
$table->string('snapshot_ref')->nullable()->comment('Snapshot ID / moRef from vCenter');
$table->string('vcenter_task_id')->nullable()->comment('Task ID from vCenter');
$table->unsignedBigInteger('size_bytes')
->nullable()
->comment('Snapshot size in bytes');
$table->decimal('size_gb', 10, 2)
->nullable()
->comment('Snapshot size in GB');
$table->timestamp('size_last_synced_at')
->nullable()
->comment('Last time snapshot size was synced');
// Error handling
$table->text('error_message')->nullable();
$table->timestamps();
$table->foreign('customer_id')
->references('id')
->on('customers')
->nullOnDelete();
$table->foreign('module_vmware_id')
->references('id')
->on('module_vmware')
->nullOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('module_snapshots');
}
};