Produktiv- und Testtabellen per Prefix trennen
This commit is contained in:
@@ -25,6 +25,16 @@ if ($baseUrl !== '' && (!str_starts_with($baseUrl, 'https://') || parse_url($bas
|
||||
$errors[] = 'APP_BASE_URL muss eine HTTPS-URL auf APP_HOST sein.';
|
||||
}
|
||||
|
||||
try {
|
||||
$dbTablePrefix = app_db_table_prefix();
|
||||
if ($dbTablePrefix === '') {
|
||||
$errors[] = 'DB_TABLE_PREFIX ist leer; Produktion und Test wären in derselben Datenbank nicht sicher getrennt.';
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$dbTablePrefix = '';
|
||||
$errors[] = 'DB_TABLE_PREFIX ist ungültig: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
$phone = app_legal_phone();
|
||||
if (strlen(preg_replace('/\D/', '', $phone) ?? '') < 7) {
|
||||
$errors[] = 'LEGAL_PHONE fehlt oder ist unplausibel; B2C darf so nicht freigeschaltet werden.';
|
||||
@@ -66,10 +76,13 @@ if (preg_match('~@import\s+url\(["\']?https?://|url\(["\']?https?://~i', $mainCs
|
||||
try {
|
||||
$pdo = app_db_pdo();
|
||||
foreach (['legal_acceptances', 'legal_requests', 'tenant_billing', 'rate_limit_attempts'] as $table) {
|
||||
$stmt = $pdo->prepare('SHOW TABLES LIKE ?');
|
||||
$stmt->execute([$table]);
|
||||
$stmt = $pdo->prepare(
|
||||
'SELECT 1 FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?'
|
||||
);
|
||||
$stmt->execute([app_db_table_name($table)]);
|
||||
if ($stmt->fetchColumn() === false) {
|
||||
$errors[] = "Datenbanktabelle {$table} fehlt; Migrationen ausführen.";
|
||||
$errors[] = "Datenbanktabelle " . app_db_table_name($table) . ' fehlt; Migrationen ausführen.';
|
||||
}
|
||||
}
|
||||
$stmt = $pdo->prepare('SELECT COUNT(*) FROM schema_migrations WHERE version = ?');
|
||||
|
||||
Reference in New Issue
Block a user