prevent peer duplicate

This commit is contained in:
xiaomlove
2022-02-17 01:10:08 +08:00
parent 553e10892f
commit 80bf8a29ff
2 changed files with 32 additions and 11 deletions
@@ -18,8 +18,8 @@ class CreatePeersTable extends Migration
}
Schema::create('peers', function (Blueprint $table) {
$table->increments('id');
$table->unsignedMediumInteger('torrent')->default(0)->index('torrent');
$table->binary('peer_id');
$table->unsignedMediumInteger('torrent')->default(0);
$table->char('peer_id', 20)->charset('binary');
$table->string('ip', 64)->default('');
$table->unsignedSmallInteger('port')->default(0);
$table->unsignedBigInteger('uploaded')->default(0);
@@ -36,6 +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']);
});
}