mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-08 17:02:41 +00:00
Address the schema changing on the service
This commit is contained in:
parent
d5652296ea
commit
df185bbe42
4 changed files with 10 additions and 1 deletions
|
@ -38,6 +38,7 @@ abstract class AbstractException extends \Exception {
|
|||
"Db/Exception.updateFileUnreadable" => 10216,
|
||||
"Db/Exception.updateFileError" => 10217,
|
||||
"Db/Exception.updateFileIncomplete" => 10218,
|
||||
"Db/Exception.updateSchemaChange" => 10219,
|
||||
"Db/Exception.paramTypeInvalid" => 10221,
|
||||
"Db/Exception.paramTypeUnknown" => 10222,
|
||||
"Db/Exception.paramTypeMissing" => 10223,
|
||||
|
|
|
@ -25,7 +25,7 @@ use JKingWeb\Arsse\Rule\Exception as RuleException;
|
|||
*
|
||||
* - Users
|
||||
* - Subscriptions to feeds, which belong to users
|
||||
* - Folders, which belong to users and contain subscriptions
|
||||
* - Folders, which belong to users and contain subscriptions or other folders
|
||||
* - Tags, which belong to users and can be assigned to multiple subscriptions
|
||||
* - Icons, which are associated with subscriptions
|
||||
* - Articles, which belong to subscriptions
|
||||
|
@ -76,9 +76,15 @@ class Database {
|
|||
public function __construct($initialize = true) {
|
||||
$driver = Arsse::$conf->dbDriver;
|
||||
$this->db = $driver::create();
|
||||
$this->checkSchemaVersion($initialize);
|
||||
}
|
||||
|
||||
public function checkSchemaVersion(bool $initialize = false): void {
|
||||
$ver = $this->db->schemaVersion();
|
||||
if ($initialize && $ver < self::SCHEMA_VERSION) {
|
||||
$this->db->schemaUpdate(self::SCHEMA_VERSION);
|
||||
} elseif ($ver != self::SCHEMA_VERSION) {
|
||||
throw new Db\Exception("updateSchemaChange");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class Service {
|
|||
}
|
||||
|
||||
public function checkIn(): bool {
|
||||
Arsse::$db->checkSchemaVersion();
|
||||
return Arsse::$db->metaSet("service_last_checkin", time(), "datetime");
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ return [
|
|||
0 {Automatic updating of the {driver_name} database failed because it is already up to date with the requested version, {target}}
|
||||
other {Automatic updating of the {driver_name} database failed because its version, {current}, is newer than the requested version, {target}}
|
||||
}',
|
||||
'Exception.JKingWeb/Arsse/Db/Exception.updateSchemaChange' => 'Database schema version has changed since the application was started; application restart is required',
|
||||
'Exception.JKingWeb/Arsse/Db/Exception.engineErrorGeneral' => '{0}',
|
||||
// indicates programming error
|
||||
'Exception.JKingWeb/Arsse/Db/Exception.savepointStatusUnknown' => 'Savepoint status code {0} not implemented',
|
||||
|
|
Loading…
Reference in a new issue