mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 18:51:13 +01:00
Update example
This commit is contained in:
parent
26b900cf61
commit
6f5dec19ec
@ -24,6 +24,7 @@ use danog\MadelineProto\Settings;
|
|||||||
use danog\MadelineProto\Settings\Database\Mysql;
|
use danog\MadelineProto\Settings\Database\Mysql;
|
||||||
use danog\MadelineProto\Settings\Database\Postgres;
|
use danog\MadelineProto\Settings\Database\Postgres;
|
||||||
use danog\MadelineProto\Settings\Database\Redis;
|
use danog\MadelineProto\Settings\Database\Redis;
|
||||||
|
use danog\MadelineProto\Settings\Database\SerializerType;
|
||||||
|
|
||||||
// If a stable version of MadelineProto was installed via composer, load composer autoloader
|
// If a stable version of MadelineProto was installed via composer, load composer autoloader
|
||||||
if (file_exists('vendor/autoload.php')) {
|
if (file_exists('vendor/autoload.php')) {
|
||||||
@ -57,7 +58,7 @@ class MyEventHandler extends EventHandler
|
|||||||
* @see https://docs.madelineproto.xyz/docs/DATABASE.html
|
* @see https://docs.madelineproto.xyz/docs/DATABASE.html
|
||||||
*/
|
*/
|
||||||
protected static array $dbProperties = [
|
protected static array $dbProperties = [
|
||||||
'dataStoredOnDb' => [],
|
'dataStoredOnDb' => ['serializer' => SerializerType::SERIALIZE],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@ use danog\MadelineProto\Settings\DatabaseAbstract;
|
|||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-type TOrmConfig=array{serializer?: SerializerType, enableCache?: bool, cacheTtl?: int}
|
* @psalm-import-type TOrmConfig from DbPropertiesTrait
|
||||||
* This factory class initializes the correct database backend for MadelineProto.
|
* This factory class initializes the correct database backend for MadelineProto.
|
||||||
*/
|
*/
|
||||||
abstract class DbPropertiesFactory
|
abstract class DbPropertiesFactory
|
||||||
|
@ -15,8 +15,7 @@ use function Amp\Future\await;
|
|||||||
*
|
*
|
||||||
* You will have to define a `$dbProperties` static array property, with a list of properties you want to store to a database.
|
* You will have to define a `$dbProperties` static array property, with a list of properties you want to store to a database.
|
||||||
*
|
*
|
||||||
* @psalm-import-type TOrmConfig from DbPropertiesFactory
|
* @psalm-type TOrmConfig=array{serializer?: SerializerType, enableCache?: bool, cacheTtl?: int}
|
||||||
*
|
|
||||||
* @property array<string, TOrmConfig> $dbProperties
|
* @property array<string, TOrmConfig> $dbProperties
|
||||||
*/
|
*/
|
||||||
trait DbPropertiesTrait
|
trait DbPropertiesTrait
|
||||||
|
@ -53,20 +53,6 @@ final class Postgres
|
|||||||
ENCODING utf8
|
ENCODING utf8
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
$connection->query("
|
|
||||||
CREATE OR REPLACE FUNCTION update_ts()
|
|
||||||
RETURNS TRIGGER AS $$
|
|
||||||
BEGIN
|
|
||||||
IF row(NEW.*) IS DISTINCT FROM row(OLD.*) THEN
|
|
||||||
NEW.ts = now();
|
|
||||||
RETURN NEW;
|
|
||||||
ELSE
|
|
||||||
RETURN OLD;
|
|
||||||
END IF;
|
|
||||||
END;
|
|
||||||
$$ language 'plpgsql'
|
|
||||||
");
|
|
||||||
$connection->close();
|
$connection->close();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Logger::log($e->getMessage(), Logger::ERROR);
|
Logger::log($e->getMessage(), Logger::ERROR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user