mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-09 17:32:40 +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.updateFileUnreadable" => 10216,
|
||||||
"Db/Exception.updateFileError" => 10217,
|
"Db/Exception.updateFileError" => 10217,
|
||||||
"Db/Exception.updateFileIncomplete" => 10218,
|
"Db/Exception.updateFileIncomplete" => 10218,
|
||||||
|
"Db/Exception.updateSchemaChange" => 10219,
|
||||||
"Db/Exception.paramTypeInvalid" => 10221,
|
"Db/Exception.paramTypeInvalid" => 10221,
|
||||||
"Db/Exception.paramTypeUnknown" => 10222,
|
"Db/Exception.paramTypeUnknown" => 10222,
|
||||||
"Db/Exception.paramTypeMissing" => 10223,
|
"Db/Exception.paramTypeMissing" => 10223,
|
||||||
|
|
|
@ -25,7 +25,7 @@ use JKingWeb\Arsse\Rule\Exception as RuleException;
|
||||||
*
|
*
|
||||||
* - Users
|
* - Users
|
||||||
* - Subscriptions to feeds, which belong to 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
|
* - Tags, which belong to users and can be assigned to multiple subscriptions
|
||||||
* - Icons, which are associated with subscriptions
|
* - Icons, which are associated with subscriptions
|
||||||
* - Articles, which belong to subscriptions
|
* - Articles, which belong to subscriptions
|
||||||
|
@ -76,9 +76,15 @@ class Database {
|
||||||
public function __construct($initialize = true) {
|
public function __construct($initialize = true) {
|
||||||
$driver = Arsse::$conf->dbDriver;
|
$driver = Arsse::$conf->dbDriver;
|
||||||
$this->db = $driver::create();
|
$this->db = $driver::create();
|
||||||
|
$this->checkSchemaVersion($initialize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkSchemaVersion(bool $initialize = false): void {
|
||||||
$ver = $this->db->schemaVersion();
|
$ver = $this->db->schemaVersion();
|
||||||
if ($initialize && $ver < self::SCHEMA_VERSION) {
|
if ($initialize && $ver < self::SCHEMA_VERSION) {
|
||||||
$this->db->schemaUpdate(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 {
|
public function checkIn(): bool {
|
||||||
|
Arsse::$db->checkSchemaVersion();
|
||||||
return Arsse::$db->metaSet("service_last_checkin", time(), "datetime");
|
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}}
|
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}}
|
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}',
|
'Exception.JKingWeb/Arsse/Db/Exception.engineErrorGeneral' => '{0}',
|
||||||
// indicates programming error
|
// indicates programming error
|
||||||
'Exception.JKingWeb/Arsse/Db/Exception.savepointStatusUnknown' => 'Savepoint status code {0} not implemented',
|
'Exception.JKingWeb/Arsse/Db/Exception.savepointStatusUnknown' => 'Savepoint status code {0} not implemented',
|
||||||
|
|
Loading…
Reference in a new issue