query("SELECT to_regclass('public.journal_deduction_categories')"); $exists = $stmt->fetchColumn(); if ($exists) { echo "Tabelle journal_deduction_categories existiert bereits.\n"; } else { // Tabelle erstellen $pdo->exec("CREATE TABLE journal_deduction_categories ( id SERIAL PRIMARY KEY, name VARCHAR(100) NOT NULL, sort_order INTEGER DEFAULT 0, is_active BOOLEAN DEFAULT TRUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"); echo "Tabelle journal_deduction_categories erstellt.\n"; // Standard-Abzüge einfügen $pdo->exec("INSERT INTO journal_deduction_categories (name, sort_order, is_active) VALUES ('Skonto', 1, TRUE), ('Lotto', 2, TRUE) "); echo "Standard-Abzüge (Skonto, Lotto) eingefügt.\n"; } echo "Migration erfolgreich!\n"; } catch (PDOException $e) { echo "Fehler: " . $e->getMessage() . "\n"; exit(1); }