From 24a2af151ea71797156db095c6bb0402de7cfd21 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sun, 13 Mar 2022 22:47:53 +0800 Subject: [PATCH] drop column torrents.tags --- nexus/Install/Update.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 9c180ef3..982f35ca 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -191,17 +191,18 @@ class Update extends Install $this->doLog(__METHOD__ . ", laravel is not available"); return; } - if ( - NexusDB::schema()->hasColumn('torrents', 'tags') - && Torrent::query()->where('tags', '>', 0)->count() > 0 - && TorrentTag::query()->count() == 0 - ) { - $this->doLog("[MIGRATE_TORRENT_TAG]..."); - $tagRep = new TagRepository(); - $tagRep->migrateTorrentTag(); - $this->doLog("[MIGRATE_TORRENT_TAG] done!"); + if (NexusDB::schema()->hasColumn('torrents', 'tags')) { + if (Torrent::query()->where('tags', '>', 0)->count() > 0 && TorrentTag::query()->count() == 0) { + $this->doLog("[MIGRATE_TORRENT_TAG]..."); + $tagRep = new TagRepository(); + $tagRep->migrateTorrentTag(); + $this->doLog("[MIGRATE_TORRENT_TAG] done!"); + } + $sql = 'alter table torrents drop column tags'; + sql_query($sql); + $this->doLog($sql); } else { - $this->doLog("no need to run [MIGRATE_TORRENT_TAG]"); + $this->doLog("torrents table does not has column: tags"); } }