[Web] Create events in docker entrypoint of PHP-FPM
This commit is contained in:
parent
be5ee4a0ae
commit
e03cd5f082
@ -3,7 +3,7 @@ function init_db_schema() {
|
|||||||
try {
|
try {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
|
|
||||||
$db_version = "1102019_1040";
|
$db_version = "06112019_1840";
|
||||||
|
|
||||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
@ -1047,31 +1047,6 @@ function init_db_schema() {
|
|||||||
$pdo->query($create);
|
$pdo->query($create);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create events to clean database
|
|
||||||
$events[] = 'DROP EVENT IF EXISTS clean_spamalias;
|
|
||||||
DELIMITER //
|
|
||||||
CREATE EVENT clean_spamalias
|
|
||||||
ON SCHEDULE EVERY 1 DAY DO
|
|
||||||
BEGIN
|
|
||||||
DELETE FROM spamalias WHERE validity < UNIX_TIMESTAMP();
|
|
||||||
END;
|
|
||||||
//
|
|
||||||
DELIMITER ;';
|
|
||||||
$events[] = 'DROP EVENT IF EXISTS clean_oauth2;
|
|
||||||
DELIMITER //
|
|
||||||
CREATE EVENT clean_oauth2
|
|
||||||
ON SCHEDULE EVERY 1 DAY DO
|
|
||||||
BEGIN
|
|
||||||
DELETE FROM oauth_refresh_tokens WHERE expires < NOW();
|
|
||||||
DELETE FROM oauth_access_tokens WHERE expires < NOW();
|
|
||||||
DELETE FROM oauth_authorization_codes WHERE expires < NOW();
|
|
||||||
END;
|
|
||||||
//
|
|
||||||
DELIMITER ;';
|
|
||||||
foreach ($events as $event) {
|
|
||||||
$pdo->exec($event);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inject admin if not exists
|
// Inject admin if not exists
|
||||||
$stmt = $pdo->query("SELECT NULL FROM `admin`");
|
$stmt = $pdo->query("SELECT NULL FROM `admin`");
|
||||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
|
Loading…
Reference in New Issue
Block a user