# Generated by Django 5.2.7 on 2026-01-27 18:13

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='Наименование')),
            ],
            options={
                'verbose_name': 'Категория',
                'verbose_name_plural': 'Категории',
            },
        ),
        migrations.CreateModel(
            name='FleetUnit',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Наименование')),
                ('model_name', models.CharField(max_length=255, verbose_name='Модель')),
                ('vin', models.CharField(max_length=100, unique=True, verbose_name='VIN / Серийный номер')),
                ('plate_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='Госномер')),
                ('year', models.PositiveIntegerField(verbose_name='Год выпуска')),
                ('photo', models.ImageField(blank=True, null=True, upload_to='fleet_photos/', verbose_name='Фото')),
                ('status', models.CharField(choices=[('active', 'В работе'), ('idle', 'Простаивает'), ('broken', 'Сломана'), ('repair', 'В ремонте'), ('waiting_parts', 'Ждёт деталь')], default='active', max_length=20, verbose_name='Статус')),
                ('commissioning_date', models.DateField(verbose_name='Дата ввода в эксплуатацию')),
                ('notes', models.TextField(blank=True, null=True, verbose_name='Примечания')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.category', verbose_name='Категория')),
            ],
            options={
                'verbose_name': 'Техника',
                'verbose_name_plural': 'Техника',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Breakdown',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(auto_now_add=True, verbose_name='Дата')),
                ('system_node', models.CharField(max_length=255, verbose_name='Узел / система')),
                ('description', models.TextField(verbose_name='Описание')),
                ('status', models.CharField(choices=[('reported', 'Заявлено'), ('repaired', 'Отремонтировано'), ('need_part', 'Нужна деталь')], default='reported', max_length=20, verbose_name='Статус')),
                ('repair_date', models.DateField(blank=True, null=True, verbose_name='Дата ремонта')),
                ('cost', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='Стоимость')),
                ('fleet_unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='breakdowns', to='core.fleetunit', verbose_name='Техника')),
            ],
            options={
                'verbose_name': 'Поломка',
                'verbose_name_plural': 'Поломки',
            },
        ),
        migrations.CreateModel(
            name='Maintenance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('m_type', models.CharField(choices=[('TO-250', 'ТО-250'), ('TO-500', 'ТО-500'), ('seasonal', 'Сезонное'), ('individual', 'Индивидуальное')], max_length=50, verbose_name='Тип ТО')),
                ('planned_date', models.DateField(verbose_name='Плановая дата')),
                ('planned_runtime', models.PositiveIntegerField(verbose_name='Плановый пробег / моточасы')),
                ('status', models.CharField(choices=[('planned', 'Планируется'), ('in_progress', 'В процессе'), ('completed', 'Выполнено')], default='planned', max_length=20, verbose_name='Статус')),
                ('actual_date', models.DateField(blank=True, null=True, verbose_name='Фактическая дата')),
                ('actual_runtime', models.PositiveIntegerField(blank=True, null=True, verbose_name='Фактический пробег / моточасы')),
                ('notes', models.TextField(blank=True, null=True, verbose_name='Примечания')),
                ('fleet_unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='maintenances', to='core.fleetunit', verbose_name='Техника')),
            ],
            options={
                'verbose_name': 'ТО',
                'verbose_name_plural': 'ТО',
            },
        ),
        migrations.CreateModel(
            name='PartRequest',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('part_name', models.CharField(max_length=255, verbose_name='Наименование детали')),
                ('article_number', models.CharField(blank=True, max_length=100, null=True, verbose_name='Артикул')),
                ('quantity', models.PositiveIntegerField(default=1, verbose_name='Количество')),
                ('status', models.CharField(choices=[('draft', 'Черновик'), ('sent', 'Отправлено'), ('ordered', 'Заказано'), ('delivered', 'Доставлено')], default='draft', max_length=20, verbose_name='Статус')),
                ('photo', models.ImageField(blank=True, null=True, upload_to='part_photos/', verbose_name='Фото')),
                ('notes', models.TextField(blank=True, null=True, verbose_name='Примечание')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('fleet_unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='part_requests', to='core.fleetunit', verbose_name='Техника')),
            ],
            options={
                'verbose_name': 'Заявка на запчасть',
                'verbose_name_plural': 'Заявки на запчасти',
            },
        ),
        migrations.CreateModel(
            name='Document',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('doc_type', models.CharField(choices=[('passport', 'Паспорт'), ('maintenance_act', 'Акт ТО'), ('photo', 'Фото'), ('invoice', 'Счет')], max_length=50, verbose_name='Тип документа')),
                ('file', models.FileField(upload_to='documents/', verbose_name='Файл')),
                ('uploaded_at', models.DateTimeField(auto_now_add=True, verbose_name='Дата добавления')),
                ('breakdown', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='core.breakdown')),
                ('fleet_unit', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='core.fleetunit')),
                ('maintenance', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='core.maintenance')),
                ('part_request', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='core.partrequest')),
            ],
            options={
                'verbose_name': 'Документ',
                'verbose_name_plural': 'Документы',
            },
        ),
    ]
