From 6e76f6be547c4c59daeae54466927d672c84ba85 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 28 Oct 2022 23:30:24 +0800 Subject: [PATCH] fix migrate searchbox --- app/Console/Commands/NexusUpdate.php | 11 ++++++++--- nexus/Install/Update.php | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/NexusUpdate.php b/app/Console/Commands/NexusUpdate.php index 8d281b2d..8c72edd7 100644 --- a/app/Console/Commands/NexusUpdate.php +++ b/app/Console/Commands/NexusUpdate.php @@ -12,14 +12,14 @@ class NexusUpdate extends Command * * @var string */ - protected $signature = 'nexus:update {--tag=} {--keep_tmp} {--include_composer}'; + protected $signature = 'nexus:update {--tag=} {--branch=} {--keep_tmp} {--include_composer}'; /** * The console command description. * * @var string */ - protected $description = 'Update nexusphp after code updated, remember run `composer update` first. Options: --tag=, --keep_tmp, --include_composer'; + protected $description = 'Update nexusphp after code updated, remember run `composer update` first. Options: --tag=, --branch, --keep_tmp, --include_composer'; private $update; @@ -44,6 +44,7 @@ class NexusUpdate extends Command define('WITH_LARAVEL', true); require ROOT_PATH . 'nexus/Database/helpers.php'; $tag = $this->option('tag'); + $branch = $this->option('branch'); $keepTmp = $this->option('keep_tmp'); $includeComposer = $this->option('include_composer'); $includes = []; @@ -68,7 +69,11 @@ class NexusUpdate extends Command //Download if ($tag !== null) { if ($tag === 'dev') { - $url = "https://github.com/xiaomlove/nexusphp/archive/refs/heads/php8.zip"; + if ($branch) { + $url = "https://github.com/xiaomlove/nexusphp/archive/refs/heads/{$branch}.zip"; + } else { + $url = "https://github.com/xiaomlove/nexusphp/archive/refs/heads/php8.zip"; + } } else { if (!str_starts_with($tag, 'v')) { $tag = "v$tag"; diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 6c51663c..278531f3 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -259,7 +259,16 @@ class Update extends Install /** * @since 1.8.0 */ + $shouldMigrateSearchBox = false; if (!NexusDB::hasColumn('searchbox', 'section_name')) { + $shouldMigrateSearchBox = true; + } else { + $columnInfo = NexusDB::getMysqlColumnInfo('searchbox', 'section_name'); + if ($columnInfo['DATA_TYPE'] != 'json') { + $shouldMigrateSearchBox = true; + } + } + if ($shouldMigrateSearchBox) { $this->runMigrate('database/migrations/2022_09_05_230532_add_mode_to_section_related.php'); $this->runMigrate('database/migrations/2022_09_06_004318_add_section_name_to_searchbox_table.php'); $this->runMigrate('database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php'); @@ -267,6 +276,7 @@ class Update extends Install $searchBoxRep->migrateToModeRelated(); $this->doLog("[MIGRATE_TAXONOMY_TO_MODE_RELATED]"); } + $this->removeMenu(['catmanage.php']); }