-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathVersion13000Date20251031165700.php
More file actions
57 lines (50 loc) · 1.63 KB
/
Version13000Date20251031165700.php
File metadata and controls
57 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Migration;
use Closure;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
use OCP\DB\ISchemaWrapper;
use OCP\IAppConfig;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;
class Version13000Date20251031165700 extends SimpleMigrationStep {
public function __construct(
private IAppConfig $appConfig,
private CertificateEngineFactory $certificateEngineFactory,
) {
}
/**
* Fix config path for OpenSSL engine when this info does not exist
*
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
* @return null|ISchemaWrapper
*/
#[Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$engineName = $this->appConfig->getValueString(Application::APP_ID, 'certificate_engine', 'openssl');
if ($engineName === 'openssl') {
$engine = $this->certificateEngineFactory->getEngine();
$configPath = $this->appConfig->getValueString(Application::APP_ID, 'config_path', '');
if ($configPath === '') {
$engine->setConfigPath($engine->getConfigPath());
}
}
if ($schema->hasTable('libresign_crl')) {
$crlTable = $schema->getTable('libresign_crl');
if (!$crlTable->hasColumn('engine')) {
$crlTable->addColumn('engine', 'string', ['default' => $engineName]);
}
}
return $schema;
}
}