Upload via GUI (346 Dateien)
This commit is contained in:
@@ -1820,6 +1820,36 @@ function run_migrations(PDO $pdo, bool $verbose = false): array
|
||||
}
|
||||
}
|
||||
|
||||
// Warteschlange für ausgehende Mails: Fehlgeschlagene Mails werden später erneut versucht
|
||||
if (!isset($done['php_0064_mail_queue'])) {
|
||||
try {
|
||||
$drv = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
$ai = $drv === 'sqlite' ? 'INTEGER PRIMARY KEY AUTOINCREMENT' : 'INT AUTO_INCREMENT PRIMARY KEY';
|
||||
$long = $drv === 'sqlite' ? 'TEXT' : 'MEDIUMTEXT';
|
||||
$eng = $drv === 'sqlite' ? '' : ' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4';
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS mail_queue (
|
||||
id $ai,
|
||||
to_email VARCHAR(255) NOT NULL,
|
||||
from_header VARCHAR(255) NULL,
|
||||
subject VARCHAR(500) NOT NULL,
|
||||
body $long NOT NULL,
|
||||
status VARCHAR(10) NOT NULL DEFAULT 'pending',
|
||||
attempts INT NOT NULL DEFAULT 0,
|
||||
next_attempt_at DATETIME NOT NULL,
|
||||
last_error VARCHAR(400) NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
sent_at DATETIME NULL
|
||||
)$eng");
|
||||
$pdo->exec('CREATE INDEX idx_mail_queue_due ON mail_queue (status, next_attempt_at)');
|
||||
$pdo->prepare('INSERT INTO schema_migrations (migration) VALUES (?)')->execute(['php_0064_mail_queue']);
|
||||
$result['applied']++;
|
||||
if ($verbose) $result['log'][] = ' [OK] php_0064_mail_queue';
|
||||
} catch (Throwable $e) {
|
||||
$result['errors'][] = 'php_0064_mail_queue: ' . $e->getMessage();
|
||||
if ($verbose) $result['log'][] = ' [FAIL] php_0064_mail_queue - ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user