Skip to content

Commit a74a2c3

Browse files
committed
torrents table last_action add index
1 parent d06d677 commit a74a2c3

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

app/Console/Commands/Upgrade/MigrateTorrentsTableTextColumn.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class MigrateTorrentsTableTextColumn extends Command
2828
*/
2929
public function handle()
3030
{
31+
if (Schema::hasTable("torrent_extras") && Schema::hasColumn("torrents", "descr")) {
32+
NexusDB::statement("insert into torrent_extras (torrent_id, descr, media_info, nfo, created_at) select id, descr, technical_info, nfo, now() from torrents on duplicate key update torrent_id = values(torrent_id)");
33+
}
3134
$columns = ["ori_descr", "descr", "nfo", "technical_info", "pt_gen"];
3235
$sql = "alter table torrents ";
3336
$drops = [];
@@ -40,8 +43,5 @@ public function handle()
4043
$sql .= implode(",", $drops);
4144
NexusDB::statement($sql);
4245
}
43-
if (Schema::hasTable("torrent_extras")) {
44-
NexusDB::statement("insert torrent_extras (torrent_id, descr, media_info, nfo, created_at) select id, descr, technical_info, nfo, now() from torrents on duplicate key update torrent_id = values(torrent_id)");
45-
}
4646
}
4747
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('torrents', function (Blueprint $table) {
15+
$table->index('last_action');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('torrents', function (Blueprint $table) {
25+
//
26+
});
27+
}
28+
};

include/cleanup.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ function docleanup($forceAll = 0, $printProgress = false) {
333333

334334
//2.5.update torrents' visibility
335335
$deadtime = deadtime() - $max_dead_torrent_time;
336-
sql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime) AND seeders=0") or sqlerr(__FILE__, __LINE__);
336+
$lastActionDeadTime = date("Y-m-d H:i:s",$deadtime);
337+
sql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < '$lastActionDeadTime' AND seeders=0") or sqlerr(__FILE__, __LINE__);
337338
$log = "update torrents' visibility";
338339
do_log($log);
339340
if ($printProgress) {

nexus/Install/Update.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,7 @@ public function runExtraQueries()
340340
*/
341341
if (!Schema::hasTable("torrent_extras")) {
342342
$this->runMigrate("database/migrations/2025_01_08_133552_create_torrent_extra_table.php");
343-
$this->runMigrate("database/migrations/2025_01_08_133847_create_user_modify_logs_table.php");
344-
$this->runMigrate("database/migrations/2025_01_18_235747_drop_users_table_text_column.php");
345-
$this->runMigrate("database/migrations/2025_01_18_235757_drop_torrents_table_text_column.php");
346343
Artisan::call("upgrade:migrate_torrents_table_text_column");
347-
Artisan::call("upgrade:migrate_users_table_comment_related_column");
348344
}
349345
}
350346

0 commit comments

Comments
 (0)