diff --git a/app/Console/Commands/Upgrade/MigrateTorrentsTableTextColumn.php b/app/Console/Commands/Upgrade/MigrateTorrentsTableTextColumn.php index 5ca1b7f1..d11a31a5 100644 --- a/app/Console/Commands/Upgrade/MigrateTorrentsTableTextColumn.php +++ b/app/Console/Commands/Upgrade/MigrateTorrentsTableTextColumn.php @@ -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)"); - } } } diff --git a/database/migrations/2025_01_20_012625_add_index_to_torrents_table_last_action_field.php b/database/migrations/2025_01_20_012625_add_index_to_torrents_table_last_action_field.php new file mode 100644 index 00000000..250e1c23 --- /dev/null +++ b/database/migrations/2025_01_20_012625_add_index_to_torrents_table_last_action_field.php @@ -0,0 +1,28 @@ +index('last_action'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('torrents', function (Blueprint $table) { + // + }); + } +}; diff --git a/include/cleanup.php b/include/cleanup.php index 86c11855..a5ddf461 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -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) { diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 3fb82762..0e84dab1 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -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"); } }