mysql Integration

This commit is contained in:
2026-03-21 21:53:46 +01:00
parent 9ae81e8347
commit 491605b328
12 changed files with 307 additions and 95 deletions
+13 -2
View File
@@ -4,10 +4,21 @@ declare(strict_types=1);
require_once __DIR__ . '/support.php';
$outputPath = $argv[1] ?? scripts_bundle_output_path();
$options = scripts_parse_options($argv);
$outputPath = scripts_bundle_output_path();
$connection = scripts_normalize_db_connection($options['connection'] ?? scripts_read_env_file(scripts_env_path())['DB_CONNECTION'] ?? 'mysql');
foreach (array_slice($argv, 1) as $arg) {
if (scripts_string_starts_with($arg, '--')) {
continue;
}
$outputPath = $arg;
break;
}
try {
scripts_stdout(scripts_build_migration_bundle($outputPath));
scripts_stdout(scripts_build_migration_bundle($outputPath, $connection));
} catch (Throwable $exception) {
scripts_stderr($exception->getMessage());
}
+10 -2
View File
@@ -7,7 +7,11 @@ require_once __DIR__ . '/support.php';
$phpVersion = PHP_VERSION;
$composerExists = scripts_check_command('composer');
$gitExists = scripts_check_command('git');
$env = scripts_read_env_file(scripts_env_path());
$dbConnection = scripts_normalize_db_connection($env['DB_CONNECTION'] ?? 'mysql');
$pdoMysqlLoaded = extension_loaded('pdo_mysql');
$pdoSqlsrvLoaded = extension_loaded('pdo_sqlsrv');
$requiredExtension = scripts_required_pdo_extension($dbConnection);
scripts_stdout('Pruefe lokale Voraussetzungen fuer Kaffeeliste SaaS...');
scripts_stdout('Projektwurzel: ' . scripts_project_root());
@@ -17,7 +21,10 @@ $checks = [
['PHP', true, $phpVersion],
['Composer', $composerExists, $composerExists ? 'verfuegbar' : 'nicht gefunden'],
['Git', $gitExists, $gitExists ? 'verfuegbar' : 'nicht gefunden'],
['DB_CONNECTION', true, $dbConnection],
['pdo_mysql', $pdoMysqlLoaded, $pdoMysqlLoaded ? 'geladen' : 'nicht geladen'],
['pdo_sqlsrv', $pdoSqlsrvLoaded, $pdoSqlsrvLoaded ? 'geladen' : 'nicht geladen'],
['Erforderliche PDO-Erweiterung', extension_loaded($requiredExtension), $requiredExtension],
['SaaS-App', is_dir(scripts_saas_app_path()), scripts_saas_app_path()],
['.env.example', is_file(scripts_env_example_path()), scripts_env_example_path()],
['.env', is_file(scripts_env_path()), is_file(scripts_env_path()) ? 'vorhanden' : 'noch nicht angelegt'],
@@ -32,5 +39,6 @@ scripts_stdout('');
scripts_stdout('Naechste Schritte:');
scripts_stdout('1. Falls Composer fehlt, zuerst Composer installieren.');
scripts_stdout('2. Mit `php scripts/prepare-saas-env.php` eine lokale .env anlegen.');
scripts_stdout('3. Mit `php scripts/install-saas.php` das SQL-Bundle erzeugen.');
scripts_stdout('4. Optional `php scripts/run-sql-migrations.php --server=... --database=...` fuer die direkte SQL-Ausfuehrung verwenden.');
scripts_stdout('3. DB_CONNECTION in `saas-app/.env` auf mysql, mariadb oder sqlsrv pruefen.');
scripts_stdout('4. Mit `php scripts/install-saas.php` das SQL-Bundle fuer den gewaehlten Treiber erzeugen.');
scripts_stdout('5. Optional `php scripts/run-sql-migrations.php --connection=' . $dbConnection . ' --server=... --database=...` fuer die direkte SQL-Ausfuehrung verwenden.');
+5 -3
View File
@@ -28,14 +28,16 @@ if ($prepareEnv) {
}
try {
$bundlePath = scripts_build_migration_bundle();
$envValues = scripts_read_env_file(scripts_env_path());
$dbConnection = scripts_normalize_db_connection($envValues['DB_CONNECTION'] ?? 'mysql');
$bundlePath = scripts_build_migration_bundle(null, $dbConnection);
} catch (Throwable $exception) {
scripts_stderr($exception->getMessage());
}
scripts_stdout('');
scripts_stdout('SQL-Bundle erzeugt: ' . $bundlePath);
scripts_stdout('SQL-Bundle fuer ' . scripts_connection_label($dbConnection) . ' erzeugt: ' . $bundlePath);
scripts_stdout('Naechste Schritte:');
scripts_stdout('1. saas-app/.env mit echten DB-, Mail- und Tenancy-Werten fuellen.');
scripts_stdout('2. Das SQL-Bundle manuell importieren oder `php scripts/run-sql-migrations.php --server=... --database=...` verwenden.');
scripts_stdout('2. Das SQL-Bundle manuell importieren oder `php scripts/run-sql-migrations.php --connection=' . $dbConnection . ' --server=... --database=...` verwenden.');
scripts_stdout('3. Danach ersten Tenant, ersten Benutzer und erste Member-Zuordnung anlegen.');
+4 -2
View File
@@ -6,18 +6,20 @@ require_once __DIR__ . '/support.php';
$options = scripts_parse_options($argv);
$env = scripts_read_env_file(scripts_env_path());
$connection = scripts_normalize_db_connection($options['connection'] ?? $env['DB_CONNECTION'] ?? 'mysql');
$config = [
'connection' => $connection,
'server' => $options['server'] ?? $env['DB_HOST'] ?? null,
'database' => $options['database'] ?? $env['DB_DATABASE'] ?? null,
'port' => $options['port'] ?? $env['DB_PORT'] ?? '1433',
'port' => $options['port'] ?? $env['DB_PORT'] ?? scripts_default_db_port($connection),
'username' => $options['username'] ?? $env['DB_USERNAME'] ?? null,
'password' => $options['password'] ?? $env['DB_PASSWORD'] ?? null,
];
try {
scripts_run_sql_migrations($config);
scripts_stdout('Migrationen wurden erfolgreich ausgefuehrt.');
scripts_stdout('Migrationen fuer ' . scripts_connection_label($connection) . ' wurden erfolgreich ausgefuehrt.');
} catch (Throwable $exception) {
scripts_stderr('Migration fehlgeschlagen: ' . $exception->getMessage());
}