# Generated by Django 5.2.8 on 2025-11-28 03:43

from django.db import migrations


def create_default_resource_types(apps, schema_editor):
    """Create default resource types for all tenants"""
    ResourceType = apps.get_model('schedule', 'ResourceType')

    # Create default types if they don't exist
    ResourceType.objects.get_or_create(
        name='Staff',
        defaults={
            'category': 'STAFF',
            'is_default': True,
            'icon_name': 'user'
        }
    )
    ResourceType.objects.get_or_create(
        name='Room',
        defaults={
            'category': 'OTHER',
            'is_default': True,
            'icon_name': 'home'
        }
    )
    ResourceType.objects.get_or_create(
        name='Equipment',
        defaults={
            'category': 'OTHER',
            'is_default': True,
            'icon_name': 'wrench'
        }
    )


def reverse_default_resource_types(apps, schema_editor):
    """Remove default resource types (for rollback)"""
    ResourceType = apps.get_model('schedule', 'ResourceType')
    ResourceType.objects.filter(is_default=True).delete()


class Migration(migrations.Migration):

    dependencies = [
        ('schedule', '0007_alter_resource_type_resourcetype_and_more'),
    ]

    operations = [
        migrations.RunPython(create_default_resource_types, reverse_default_resource_types),
    ]
