from django.core.management.base import BaseCommand
from django.db import connection
from apps.organization.models import Company
from apps.employees.models import Employee

class Command(BaseCommand):
    help = "Check database connectivity and key HR/Payroll bootstrap records."

    def handle(self, *args, **options):
        with connection.cursor() as cursor:
            cursor.execute("SELECT 1")
            cursor.fetchone()
        self.stdout.write(self.style.SUCCESS("Database connection: OK"))
        self.stdout.write(f"Companies: {Company.objects.count()}")
        self.stdout.write(f"Employees: {Employee.objects.count()}")
        if not Company.objects.exists():
            self.stdout.write(self.style.WARNING("No company found. Run seed_reference_data after migrations."))
