"""
Create a default tenant for local development
"""
from smoothschedule.identity.core.models import Tenant, Domain
from django.contrib.auth import get_user_model

User = get_user_model()

# Create default tenant for local development
tenant, created = Tenant.objects.get_or_create(
    schema_name='public',
    defaults={
        'name': 'Default Tenant',
        'subscription_tier': 'PROFESSIONAL',
        'max_users': 100,
        'max_resources': 100,
    }
)

if created:
    print(f"Created tenant: {tenant.name}")
else:
    print(f"Tenant already exists: {tenant.name}")

# Create domain for localhost
domain, created = Domain.objects.get_or_create(
    domain='localhost',
    defaults={
        'tenant': tenant,
        'is_primary': True,
    }
)

if created:
    print(f"Created domain: {domain.domain}")
else:
    print(f"Domain already exists: {domain.domain}")
    
print("Setup complete!")
