exam support priority + peer suppoert ipv4&ipv6

This commit is contained in:
xiaomlove
2022-04-18 19:07:35 +08:00
parent 107da8e335
commit 55138da862
46 changed files with 302 additions and 115 deletions
@@ -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');
});
}
};