-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix config value types for some bools and ints we store
Signed-off-by: Julien Veyssier <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Assistant\Migration; | ||
|
||
use Closure; | ||
use OCA\Assistant\AppInfo\Application; | ||
use OCP\IAppConfig; | ||
use OCP\Migration\IOutput; | ||
use OCP\Migration\SimpleMigrationStep; | ||
|
||
class Version020201Date20250120174409 extends SimpleMigrationStep { | ||
|
||
public function __construct( | ||
private IAppConfig $appConfig, | ||
) { | ||
} | ||
|
||
/** | ||
* @param IOutput $output | ||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
* @param array $options | ||
* @return void | ||
*/ | ||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { | ||
// some app values were types as INT | ||
// https://github.com/nextcloud/assistant/issues/174 | ||
$keysToFix = [ | ||
'assistant_enabled', | ||
'chat_last_n_messages', | ||
'free_prompt_picker_enabled', | ||
'speech_to_text_picker_enabled', | ||
'text_to_image_picker_enabled', | ||
]; | ||
foreach ($keysToFix as $key) { | ||
if ($this->appConfig->hasKey(Application::APP_ID, $key) | ||
&& $this->appConfig->getValueType(Application::APP_ID, $key) === IAppConfig::VALUE_INT) { | ||
$value = $this->appConfig->getValueInt(Application::APP_ID, $key); | ||
$this->appConfig->deleteKey(Application::APP_ID, $key); | ||
$this->appConfig->setValueString(Application::APP_ID, $key, (string)$value); | ||
} | ||
} | ||
} | ||
} |