#!/bin/bash

# Large-Scale Database Seeding Examples
# This script demonstrates various ways to seed your database with large amounts of data

echo "🚀 Large-Scale Database Seeding Examples"
echo "========================================"

# Example 1: Basic seeding with default settings
echo "📝 Example 1: Basic seeding (100K users, 500K orders, 300K bookings)"
echo "Command: php artisan db:seed-large"
echo ""

# Example 2: Custom record counts
echo "📝 Example 2: Custom record counts (1M users, 2M orders, 1M bookings)"
echo "Command: php artisan db:seed-large --users=1000000 --orders=2000000 --bookings=1000000"
echo ""

# Example 3: Optimized for memory
echo "📝 Example 3: Memory-optimized seeding (smaller batches, more memory)"
echo "Command: php artisan db:seed-large --batch-size=500 --memory-limit=4G"
echo ""

# Example 4: Fresh migration
echo "📝 Example 4: Fresh migration before seeding"
echo "Command: php artisan db:seed-large --fresh"
echo ""

# Example 5: Performance testing
echo "📝 Example 5: Run performance tests"
echo "Command: php artisan db:seed --class=PerformanceSeeder"
echo ""

# Example 6: Background processing
echo "📝 Example 6: Run in background"
echo "Command: nohup php artisan db:seed-large --users=1000000 > seeding.log 2>&1 &"
echo ""

# Example 7: Monitor progress
echo "📝 Example 7: Monitor background seeding"
echo "Command: tail -f seeding.log"
echo ""

# Example 8: Chunked processing
echo "📝 Example 8: Process in chunks (for very large datasets)"
echo "Commands:"
echo "  for i in {1..10}; do"
echo "    php artisan db:seed-large --users=100000 --orders=0 --bookings=0"
echo "  done"
echo ""

# Example 9: Database optimization
echo "📝 Example 9: Optimize database before seeding"
echo "Commands:"
echo "  mysql -u root -p your_database < database/optimize.sql"
echo "  php artisan db:seed-large"
echo ""

# Example 10: Cleanup
echo "📝 Example 10: Clean up test data"
echo "Commands:"
echo "  php artisan migrate:fresh  # Complete reset"
echo "  # OR"
echo "  php artisan tinker"
echo "  >>> User::where('email', 'like', 'test_%')->delete();"
echo ""

echo "💡 Tips:"
echo "- Start with small datasets to test your setup"
echo "- Monitor memory usage during seeding"
echo "- Use background processing for very large datasets"
echo "- Always backup your database before large operations"
echo "- Check the documentation in docs/large-scale-seeding.md for more details"
echo ""

echo "🎯 Ready to seed! Choose an example and run the command."
