initial commit
This commit is contained in:
31
setup-database.php
Normal file
31
setup-database.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// setup-database.php - Komplettes Datenbank-Setup mit Migrations
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
try {
|
||||
// Datenbank neu erstellen
|
||||
$pdo = new PDO("mysql:host=$databaseHost", $databaseUser, $databasePassword);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$pdo->exec("DROP DATABASE IF EXISTS $databaseDatabase");
|
||||
$pdo->exec("CREATE DATABASE $databaseDatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
|
||||
echo "✓ Datenbank '$databaseDatabase' wurde neu erstellt.\n";
|
||||
|
||||
// Migrations ausführen
|
||||
echo "\n";
|
||||
passthru('php migrations-cli.php migrations:migrate --no-interaction', $returnCode);
|
||||
|
||||
if ($returnCode === 0) {
|
||||
echo "\n✓ Datenbank-Setup erfolgreich abgeschlossen!\n";
|
||||
echo "\nStandardbenutzer:\n";
|
||||
echo "- admin / admin123 (Rolle: admin)\n";
|
||||
echo "- testuser1 / test123 (Rolle: user)\n";
|
||||
echo "- testuser2 / test123 (Rolle: user)\n";
|
||||
} else {
|
||||
echo "\n✗ Fehler beim Ausführen der Migrations.\n";
|
||||
exit(1);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "✗ Fehler: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user