mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
exam support priority + peer suppoert ipv4&ipv6
This commit is contained in:
@@ -36,7 +36,7 @@ class CreatePeersTable extends Migration
|
||||
$table->unsignedBigInteger('downloadoffset')->default(0);
|
||||
$table->unsignedBigInteger('uploadoffset')->default(0);
|
||||
$table->char('passkey', 32)->default('');
|
||||
$table->unique(['torrent', 'peer_id']);
|
||||
$table->unique(['torrent', 'peer_id', 'ip']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableName = 'peers';
|
||||
$result = DB::select('show index from ' . $tableName);
|
||||
$indexToDrop = [];
|
||||
foreach ($result as $item) {
|
||||
if (in_array($item->Column_name, ['torrent', 'peer_id'])) {
|
||||
$indexToDrop[$item->Key_name] = "drop index " . $item->Key_name;
|
||||
}
|
||||
}
|
||||
if (!empty($indexToDrop)) {
|
||||
$sql = sprintf("alter table %s %s", $tableName, implode(', ', $indexToDrop));
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
Schema::table($tableName, function (Blueprint $table) {
|
||||
$table->unique(['torrent', 'peer_id', 'ip']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('exams', function (Blueprint $table) {
|
||||
$table->integer('priority')->default(0)->after('is_discovered');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('exams', function (Blueprint $table) {
|
||||
$table->dropColumn('priority');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user