torrents table last_action add index

This commit is contained in:
xiaomlove
2025-01-20 01:49:06 +08:00
parent d06d677565
commit a74a2c3c2a
4 changed files with 33 additions and 8 deletions
@@ -28,6 +28,9 @@ class MigrateTorrentsTableTextColumn extends Command
*/
public function handle()
{
if (Schema::hasTable("torrent_extras") && Schema::hasColumn("torrents", "descr")) {
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)");
}
$columns = ["ori_descr", "descr", "nfo", "technical_info", "pt_gen"];
$sql = "alter table torrents ";
$drops = [];
@@ -40,8 +43,5 @@ class MigrateTorrentsTableTextColumn extends Command
$sql .= implode(",", $drops);
NexusDB::statement($sql);
}
if (Schema::hasTable("torrent_extras")) {
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)");
}
}
}
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('torrents', function (Blueprint $table) {
$table->index('last_action');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('torrents', function (Blueprint $table) {
//
});
}
};
+2 -1
View File
@@ -333,7 +333,8 @@ function docleanup($forceAll = 0, $printProgress = false) {
//2.5.update torrents' visibility
$deadtime = deadtime() - $max_dead_torrent_time;
sql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime) AND seeders=0") or sqlerr(__FILE__, __LINE__);
$lastActionDeadTime = date("Y-m-d H:i:s",$deadtime);
sql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < '$lastActionDeadTime' AND seeders=0") or sqlerr(__FILE__, __LINE__);
$log = "update torrents' visibility";
do_log($log);
if ($printProgress) {
-4
View File
@@ -340,11 +340,7 @@ class Update extends Install
*/
if (!Schema::hasTable("torrent_extras")) {
$this->runMigrate("database/migrations/2025_01_08_133552_create_torrent_extra_table.php");
$this->runMigrate("database/migrations/2025_01_08_133847_create_user_modify_logs_table.php");
$this->runMigrate("database/migrations/2025_01_18_235747_drop_users_table_text_column.php");
$this->runMigrate("database/migrations/2025_01_18_235757_drop_torrents_table_text_column.php");
Artisan::call("upgrade:migrate_torrents_table_text_column");
Artisan::call("upgrade:migrate_users_table_comment_related_column");
}
}