# Generated by Django 5.0.1 on 2024-01-26 12:01

from django.db import migrations
import random

def create_initial_units(apps, schema_editor):
    Unit = apps.get_model('core', 'Unit')
    
    # 10 Ambulances
    for i in range(1, 11):
        Unit.objects.create(
            unit_id=f'AMB-{i:03}',
            unit_type='Ambulance',
            location_lat=round(random.uniform(34.0, 35.0), 6),
            location_lon=round(random.uniform(-118.0, -119.0), 6),
            status='Available'
        )

    # 5 Police Cars
    for i in range(1, 6):
        Unit.objects.create(
            unit_id=f'POL-{i:03}',
            unit_type='Police Car',
            location_lat=round(random.uniform(34.0, 35.0), 6),
            location_lon=round(random.uniform(-118.0, -119.0), 6),
            status='Available'
        )

class Migration(migrations.Migration):

    dependencies = [
        ('core', '0002_unit'),
    ]

    operations = [
        migrations.RunPython(create_initial_units),
    ]
