mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-05 03:58:39 +00:00
Remove 'total' & 'traffic' in dataflow database table
This commit is contained in:
@@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('failed_jobs', static function (Blueprint $table) {
|
||||
@@ -22,9 +19,6 @@ return new class extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
|
||||
@@ -9,9 +9,6 @@ return new class extends Migration
|
||||
|
||||
private static array $newConfigs = ['paypal_client_id', 'paypal_client_secret'];
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Config::exists()) {
|
||||
@@ -24,9 +21,6 @@ return new class extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
foreach (self::$newConfigs as $config) {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use App\Models\NodeDailyDataFlow;
|
||||
use App\Models\NodeHourlyDataFlow;
|
||||
use App\Models\UserDailyDataFlow;
|
||||
use App\Models\UserHourlyDataFlow;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('country')->where('code', '=', 'uk')->update(['code' => 'gb']);
|
||||
|
||||
Schema::table('node_daily_data_flow', function (Blueprint $table) {
|
||||
$table->dropColumn(['total', 'traffic']);
|
||||
});
|
||||
Schema::table('node_hourly_data_flow', function (Blueprint $table) {
|
||||
$table->dropColumn(['total', 'traffic']);
|
||||
});
|
||||
Schema::table('user_daily_data_flow', function (Blueprint $table) {
|
||||
$table->dropColumn(['total', 'traffic']);
|
||||
});
|
||||
Schema::table('user_hourly_data_flow', function (Blueprint $table) {
|
||||
$table->dropColumn(['total', 'traffic']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('node_daily_data_flow', static function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('total')->default(0)->comment('总流量')->after('d');
|
||||
$table->string('traffic')->nullable()->comment('总流量(带单位)')->after('total');
|
||||
});
|
||||
foreach (NodeDailyDataFlow::cursor() as $log) {
|
||||
$log->total = $log->u + $log->d;
|
||||
$log->traffic = formatBytes($log->total);
|
||||
$log->save();
|
||||
}
|
||||
|
||||
Schema::table('node_hourly_data_flow', static function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('total')->default(0)->comment('总流量')->after('d');
|
||||
$table->string('traffic')->nullable()->comment('总流量(带单位)')->after('total');
|
||||
});
|
||||
foreach (NodeHourlyDataFlow::cursor() as $log) {
|
||||
$log->total = $log->u + $log->d;
|
||||
$log->traffic = formatBytes($log->total);
|
||||
$log->save();
|
||||
}
|
||||
|
||||
Schema::table('user_daily_data_flow', static function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('total')->default(0)->comment('总流量')->after('d');
|
||||
$table->string('traffic')->nullable()->comment('总流量(带单位)')->after('total');
|
||||
});
|
||||
foreach (UserDailyDataFlow::cursor() as $log) {
|
||||
$log->total = $log->u + $log->d;
|
||||
$log->traffic = formatBytes($log->total);
|
||||
$log->save();
|
||||
}
|
||||
|
||||
Schema::table('user_hourly_data_flow', static function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('total')->default(0)->comment('总流量')->after('d');
|
||||
$table->string('traffic')->nullable()->comment('总流量(带单位)')->after('total');
|
||||
});
|
||||
|
||||
foreach (UserHourlyDataFlow::cursor() as $log) {
|
||||
$log->total = $log->u + $log->d;
|
||||
$log->traffic = formatBytes($log->total);
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user