Skip to content

Commit 80a6298

Browse files
authored
Merge pull request #494 from wikimedia/fix-pdo-init
PDO: Move online schema creation behind feature flag
2 parents c3b042b + 3e87168 commit 80a6298

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

config/config.default.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'pass' => getenv('XHGUI_PDO_PASS') ?: null,
1919
'table' => getenv('XHGUI_PDO_TABLE') ?: 'results',
2020
'tableWatch' => getenv('XHGUI_PDO_TABLE_WATCHES') ?: 'watches',
21+
'initSchema' => getenv('XHGUI_PDO_INITSCHEMA') ?: 'true',
2122
],
2223

2324
// Database options for MongoDB.

src/Db/PdoRepository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function __construct(PDO $pdo, string $driverName, string $table, string
3434
$this->driverName = $driverName;
3535
$this->table = sprintf('"%s"', $table);
3636
$this->tableWatches = sprintf('"%s"', $tableWatch);
37-
$this->initSchema();
3837
}
3938

4039
public function getLatest(): array

src/ServiceProvider/PdoStorageProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ public function register(Container $app): void
4848
};
4949

5050
$app[PdoRepository::class] = static function ($app) {
51-
return new PdoRepository(
51+
$repo = new PdoRepository(
5252
$app['pdo'],
5353
$app['pdo.driver'],
5454
$app['config']['pdo']['table'],
5555
$app['config']['pdo']['tableWatch']
5656
);
57+
if ($app['config']['pdo']['initSchema'] === 'true') {
58+
$repo->initSchema();
59+
}
60+
return $repo;
5761
};
5862

5963
$app['searcher.pdo'] = static function ($app) {

0 commit comments

Comments
 (0)