exec($sql); echo 'Migrated: ' . basename($file) . PHP_EOL; } catch (PDOException $e) { die('Migration failed: ' . $e->getMessage()); } } // Check if default user exists $stmt = $pdo->prepare('SELECT id FROM users WHERE email = ?'); $stmt->execute(['admin@example.com']); if ($stmt->fetch()) { echo 'Default admin user already exists.' . PHP_EOL; return; } // Insert a default admin user $name = 'Super Admin'; $email = 'admin@example.com'; $password = password_hash('password', PASSWORD_DEFAULT); try { $stmt = $pdo->prepare('INSERT INTO users (name, email, password) VALUES (?, ?, ?)'); $stmt->execute([$name, $email, $password]); echo 'Default admin user created (admin@example.com / password).' . PHP_EOL; } catch (PDOException $e) { die('Failed to create default user: ' . $e->getMessage()); } } run_migrations();