User traffic can now be viewed by node

This commit is contained in:
socksprox
2025-11-29 12:37:23 +01:00
parent 95e8e7bca7
commit 9e35d16fa6
4 changed files with 243 additions and 4 deletions

View File

@@ -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('v2_stat_user', function (Blueprint $table) {
// Add server_id column as nullable for backward compatibility
$table->integer('server_id')->nullable()->after('user_id')->comment('节点ID (nullable for legacy data)');
// Add index for per-node queries
if (config('database.default') !== 'sqlite') {
$table->index(['user_id', 'server_id', 'record_at'], 'user_server_record_idx');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('v2_stat_user', function (Blueprint $table) {
if (config('database.default') !== 'sqlite') {
$table->dropIndex('user_server_record_idx');
}
$table->dropColumn('server_id');
});
}
};