Skip to content

Commit 9976be0

Browse files
committed
migrate config values to be lazy
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 81bebc3 commit 9976be0

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Setup background job workers as described here: https://docs.nextcloud.com/serve
2222
Note:
2323
Refer to the [Context Chat Backend's readme](https://github.com/nextcloud/context_chat_backend/?tab=readme-ov-file) and the [AppAPI's documentation](https://cloud-py-api.github.io/app_api/) for help with setup of AppAPI's deploy daemon.
2424
]]></description>
25-
<version>5.0.0</version>
25+
<version>5.0.1</version>
2626
<licence>agpl</licence>
2727
<author>Julien Veyssier</author>
2828
<author>Anupam Kumar</author>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\ContextChat\Migration;
11+
12+
use Closure;
13+
use OCA\ContextChat\AppInfo\Application;
14+
use OCP\DB\ISchemaWrapper;
15+
use OCP\DB\QueryBuilder\IQueryBuilder;
16+
use OCP\IDBConnection;
17+
use OCP\Migration\IOutput;
18+
use OCP\Migration\SimpleMigrationStep;
19+
use Override;
20+
21+
class Version005000001Date20251124093628 extends SimpleMigrationStep {
22+
private static array $configKeys = [
23+
'action_job_interval',
24+
'auto_indexing',
25+
'backend_init',
26+
'crawl_job_interval',
27+
'fs_listener_job_interval',
28+
'indexed_files_count',
29+
'indexing_batch_size',
30+
'indexing_job_interval',
31+
'indexing_max_size',
32+
'indexing_max_time',
33+
'installed_time',
34+
'last_indexed_file_id',
35+
'last_indexed_time',
36+
'logfile',
37+
'providers',
38+
];
39+
40+
public function __construct(
41+
private IDBConnection $connection,
42+
) {
43+
}
44+
45+
/**
46+
* @param IOutput $output
47+
* @param Closure(): ISchemaWrapper $schemaClosure
48+
* @param array $options
49+
* @return null|ISchemaWrapper
50+
*/
51+
#[Override]
52+
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
53+
$schema = $schemaClosure();
54+
55+
if (!$schema->hasTable('appconfig')) {
56+
return null;
57+
}
58+
59+
$qb = $this->connection->getQueryBuilder();
60+
$qb->update('appconfig')
61+
->set('lazy', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
62+
->where(
63+
$qb->expr()->eq('appid', $qb->createNamedParameter(Application::APP_ID, IQueryBuilder::PARAM_STR))
64+
)
65+
->andWhere(
66+
$qb->expr()->in('configkey', $qb->createNamedParameter(self::$configKeys, IQueryBuilder::PARAM_STR_ARRAY))
67+
);
68+
$qb->executeStatement();
69+
70+
return $schema;
71+
}
72+
}

lib/Migration/Version4000Date20241108004215.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace OCA\ContextChat\Migration;
1111

1212
use Closure;
13-
use OCA\ContextChat\AppInfo\Application;
1413
use OCA\ContextChat\BackgroundJobs\IndexerJob;
1514
use OCA\ContextChat\BackgroundJobs\InitialContentImportJob;
1615
use OCA\ContextChat\BackgroundJobs\SchedulerJob;

0 commit comments

Comments
 (0)