Add all files
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?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::create('ext_proxmox_nodes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_nodes');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ext_proxmox_oses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('vm_id');
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Node::class, 'node_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_oses');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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::create('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('vm_id');
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Node::class, 'node_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\OS::class, 'os_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(\App\Models\Service::class, 'service_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(\App\Models\User::class, 'user_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_servers');
|
||||
}
|
||||
};
|
||||
@@ -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::create('ext_proxmox_ipv4', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('ip')->unique();
|
||||
$table->string('gateway');
|
||||
$table->string('bridge');
|
||||
$table->string('netmask');
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Server::class, 'server_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Node::class, 'node_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_ipv4');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\IPAddress::class, 'primary_ip')->after('service_id')->constrained('ext_proxmox_ipv4')->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->dropForeign(['primary_ip']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->string('hostname')->after('primary_ip')->nullable();
|
||||
$table->string('status')->after('hostname')->default('active');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->dropColumn('hostname');
|
||||
$table->dropColumn('status');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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::create('ext_proxmox_ip_pools', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('network_interface')->default('vmbr0');
|
||||
$table->string('mtu')->default('1500');
|
||||
$table->string('vlan')->nullable();
|
||||
$table->boolean('firewall')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_ip_pools');
|
||||
}
|
||||
};
|
||||
@@ -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::create('ext_proxmox_ip_pool_nodes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\IPPool::class, 'ip_pool_id')
|
||||
->constrained('ext_proxmox_ip_pools')
|
||||
->cascadeOnDelete();
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Node::class, 'node_id')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_ip_pool_nodes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Models\Node;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::rename('ext_proxmox_ipv4', 'ext_proxmox_ip_addresses');
|
||||
|
||||
// Add mac address column
|
||||
Schema::table('ext_proxmox_ip_addresses', function (Blueprint $table) {
|
||||
$table->string('mac_address')->after('netmask')->nullable();
|
||||
$table->enum('type', ['ipv4', 'ipv6'])->default('ipv4')->after('mac_address');
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\IPPool::class, 'ip_pool_id')
|
||||
->after('node_id')
|
||||
->nullable()
|
||||
->constrained('ext_proxmox_ip_pools');
|
||||
$table->dropColumn('bridge');
|
||||
});
|
||||
|
||||
// Make ip pools for each node
|
||||
Node::all()->each(function (Node $node) {
|
||||
$ipPool = $node->ipPools()->create(['name' => $node->name . ' IP Pool']);
|
||||
|
||||
// Make all IP addresses in the pool
|
||||
\Paymenter\Extensions\Servers\Proxmox\Models\IPAddress::where('node_id', $node->id)
|
||||
->update(['ip_pool_id' => $ipPool->id]);
|
||||
});
|
||||
|
||||
// Add foreign key constraint for ip_pool_id
|
||||
Schema::table('ext_proxmox_ip_addresses', function (Blueprint $table) {
|
||||
// Make non-nullable if there are no null values
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\IPPool::class, 'ip_pool_id')->change();
|
||||
$table->dropForeign('ext_proxmox_ipv4_node_id_foreign');
|
||||
$table->dropColumn('node_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_ip_addresses', function (Blueprint $table) {
|
||||
$table->dropColumn('mac_address');
|
||||
$table->dropColumn('type');
|
||||
$table->dropForeign(['ip_pool_id']);
|
||||
$table->dropColumn('ip_pool_id');
|
||||
$table->string('bridge')->after('netmask');
|
||||
$table->foreignIdFor(Node::class, 'node_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::rename('ext_proxmox_ip_addresses', 'ext_proxmox_ipv4');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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::create('ext_proxmox_locations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('server_placement')->default('least_loaded_server');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_locations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Models\Node;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_nodes', function (Blueprint $table) {
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Location::class, 'location_id')
|
||||
->nullable()
|
||||
->constrained();
|
||||
// 0 is no limit
|
||||
$table->integer('memory')->default(0);
|
||||
$table->integer('disk')->default(0);
|
||||
$table->integer('cpu')->default(0);
|
||||
$table->string('storage_location')->default('local');
|
||||
$table->string('backup_location')->default('local');
|
||||
});
|
||||
|
||||
$server_id = App\Models\Server::where('extension', 'Proxmox')->get()->first();
|
||||
Node::all()->each(function (Node $node) use ($server_id) {
|
||||
// Create a new group
|
||||
$group = \Paymenter\Extensions\Servers\Proxmox\Models\Location::create([
|
||||
'name' => $node->name,
|
||||
'server_placement' => 'default',
|
||||
]);
|
||||
|
||||
// Assign the node to the group
|
||||
$node->location_id = $group->id;
|
||||
$node->save();
|
||||
|
||||
if (!$server_id) {
|
||||
return;
|
||||
}
|
||||
Product::where('server_id', $server_id->id)->get()->each(function (Product $product) use ($group, $node) {
|
||||
if (
|
||||
$product->settings()->where('key', 'location_id')->exists() ||
|
||||
$product->settings()->where('key', 'node')->get()->first()->value === $node->id
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$product->settings()->create([
|
||||
'key' => 'location_id',
|
||||
'value' => $group->id,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Schema::table('ext_proxmox_nodes', function (Blueprint $table) {
|
||||
// Make non-nullable if there are no null values
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Location::class, 'location_id')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Paymenter\Extensions\Servers\Proxmox\Models\Node;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_oses', function (Blueprint $table) {
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Location::class, 'location_id')
|
||||
->nullable()
|
||||
->constrained();
|
||||
});
|
||||
|
||||
Node::all()->each(function (Node $node) {
|
||||
$location = $node->location()->first();
|
||||
if (!$location) {
|
||||
return;
|
||||
}
|
||||
\Paymenter\Extensions\Servers\Proxmox\Models\OS::where('node_id', $node->id)
|
||||
->update(['location_id' => $location->id]);
|
||||
});
|
||||
|
||||
Schema::table('ext_proxmox_oses', function (Blueprint $table) {
|
||||
// Make non-nullable if there are no null values
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Location::class, 'location_id')->change();
|
||||
// Drop the old node_id column
|
||||
$table->dropForeign(['node_id']);
|
||||
$table->dropColumn('node_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->dropForeign('ext_proxmox_servers_primary_ip_foreign');
|
||||
$table->unsignedBigInteger('primary_ip')->nullable()->change();
|
||||
|
||||
// Add new foreign key constraint
|
||||
$table->foreign('primary_ip')
|
||||
->references('id')
|
||||
->on('ext_proxmox_ip_addresses')
|
||||
->nullOnDelete();
|
||||
$table->renameColumn('primary_ip', 'primary_ipv4');
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\IPAddress::class, 'primary_ipv6')->after('primary_ipv4')->nullable()->constrained('ext_proxmox_ip_addresses')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->dropForeign(['primary_ipv6']);
|
||||
$table->dropColumn('primary_ipv6');
|
||||
$table->renameColumn('primary_ipv4', 'primary_ip');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('ext_proxmox_nodes', function (Blueprint $table) {
|
||||
$table->boolean('vnc_enabled')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_nodes', function (Blueprint $table) {
|
||||
$table->dropColumn('vnc_enabled');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('ext_proxmox_servers', 'password')) {
|
||||
$table->string('password')->nullable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers', function (Blueprint $table) {
|
||||
$table->dropColumn('password');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('ext_proxmox_ip_addresses', function (Blueprint $table) {
|
||||
$table->json('subdomain')->nullable()->after('ip_pool_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_ip_addresses', function (Blueprint $table) {
|
||||
$table->dropColumn('subdomain');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE `ext_proxmox_ip_addresses` MODIFY `subdomain` LONGTEXT NULL');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE `ext_proxmox_ip_addresses` MODIFY `subdomain` JSON NULL');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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::create('ext_proxmox_servers_statistics', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\Paymenter\Extensions\Servers\Proxmox\Models\Server::class, 'server_id')->constrained('ext_proxmox_servers')->cascadeOnDelete();
|
||||
$table->bigInteger('netin')->default(0);
|
||||
$table->bigInteger('netout')->default(0);
|
||||
$table->bigInteger('memoryused')->default(0);
|
||||
$table->bigInteger('memorymax')->default(0);
|
||||
$table->decimal('cpuused', 10, 4)->default(0);
|
||||
$table->decimal('cpumax', 10, 4)->default(0);
|
||||
$table->dateTime('DateTime')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ext_proxmox_servers_statistics');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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('ext_proxmox_servers_statistics', function (Blueprint $table) {
|
||||
$table->bigInteger('diskread')->default(0)->after('netout');
|
||||
$table->bigInteger('diskwrite')->default(0)->after('diskread');
|
||||
$table->bigInteger('diskused')->default(0)->after('diskwrite');
|
||||
$table->bigInteger('diskmax')->default(0)->after('diskused');
|
||||
$table->bigInteger('uptime')->default(0)->after('diskmax');
|
||||
$table->string('vmstatus', 20)->nullable()->after('uptime');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers_statistics', function (Blueprint $table) {
|
||||
$table->dropColumn(['diskread', 'diskwrite', 'diskused', 'diskmax', 'uptime', 'vmstatus']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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
|
||||
{
|
||||
if (!Schema::hasColumn('ext_proxmox_servers_statistics', 'is_automatic')) {
|
||||
Schema::table('ext_proxmox_servers_statistics', function (Blueprint $table) {
|
||||
$table->boolean('is_automatic')->default(true)->after('vmstatus');
|
||||
$table->index(['server_id', 'is_automatic']);
|
||||
});
|
||||
|
||||
// Set all existing statistics as automatic
|
||||
\DB::table('ext_proxmox_servers_statistics')->update(['is_automatic' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ext_proxmox_servers_statistics', function (Blueprint $table) {
|
||||
$table->dropIndex(['server_id', 'is_automatic']);
|
||||
$table->dropColumn('is_automatic');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user