Files
FreshRSS/app/Models/FeedDAOSQLite.php
Alexandre Alapetite 9833d81976 Better SQL auto-update f.kind (#8148)
Add a little help to make sure that feed.kind gets added during the first call.
Tested that replacing the DB with a backup from Febuary 2020 just works, automatically adding new columns since FreshRSS 1.20.0.
2025-10-24 12:49:29 +02:00

25 lines
616 B
PHP

<?php
declare(strict_types=1);
class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO {
#[\Override]
public function sqlResetSequence(): bool {
return true; // Nothing to do for SQLite
}
/** @param array{0:string,1:int,2:string} $errorInfo */
#[\Override]
public function autoUpdateDb(array $errorInfo): bool {
if (($tableInfo = $this->pdo->query("PRAGMA table_info('feed')")) !== false) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
foreach (['kind'] as $column) {
if (!in_array($column, $columns, true)) {
return $this->addColumn($column);
}
}
}
return false;
}
}