Coverage for modules\trucking\migrations\0001_initial.py: 100%
8 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-06 16:58 +0800
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-06 16:58 +0800
1# Generated by Django 5.1.15 on 2026-09-05 13:30
3import django.db.models.deletion
4import uuid
5from decimal import Decimal
6from django.db import migrations, models
9class Migration(migrations.Migration):
11 initial = True
13 dependencies = [
14 ]
16 operations = [
17 migrations.CreateModel(
18 name='Driver',
19 fields=[
20 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
21 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
22 ('updated_at', models.DateTimeField(auto_now=True)),
23 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
24 ('first_name', models.CharField(max_length=64)),
25 ('last_name', models.CharField(max_length=64)),
26 ('email', models.EmailField(blank=True, max_length=254, null=True)),
27 ('phone', models.CharField(blank=True, max_length=32, null=True)),
28 ('license_number', models.CharField(blank=True, max_length=64, null=True)),
29 ('license_type', models.CharField(blank=True, choices=[('A', 'Class A CDL'), ('B', 'Class B CDL'), ('C', 'Class C CDL')], max_length=1, null=True)),
30 ('license_expiry', models.DateField(blank=True, null=True)),
31 ('date_of_birth', models.DateField(blank=True, null=True)),
32 ('hire_date', models.DateField(blank=True, null=True)),
33 ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('ON_LEAVE', 'On Leave'), ('TERMINATED', 'Terminated')], default='ACTIVE', max_length=16)),
34 ('address', models.TextField(blank=True, null=True)),
35 ('emergency_contact', models.CharField(blank=True, max_length=128, null=True)),
36 ('emergency_phone', models.CharField(blank=True, max_length=32, null=True)),
37 ('notes', models.TextField(blank=True, null=True)),
38 ],
39 options={
40 'ordering': ['last_name', 'first_name'],
41 },
42 ),
43 migrations.CreateModel(
44 name='Vehicle',
45 fields=[
46 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
47 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
48 ('updated_at', models.DateTimeField(auto_now=True)),
49 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
50 ('plate_number', models.CharField(db_index=True, max_length=32, unique=True)),
51 ('vin', models.CharField(blank=True, max_length=64, null=True)),
52 ('vehicle_type', models.CharField(choices=[('TRUCK', 'Box Truck'), ('SEMI', 'Semi Truck'), ('TRAILER', 'Trailer'), ('VAN', 'Cargo Van'), ('FLATBED', 'Flatbed')], default='TRUCK', max_length=16)),
53 ('make', models.CharField(blank=True, max_length=64, null=True)),
54 ('model', models.CharField(blank=True, max_length=64, null=True)),
55 ('year', models.IntegerField(blank=True, null=True)),
56 ('capacity_tons', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
57 ('fuel_type', models.CharField(blank=True, max_length=16, null=True)),
58 ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('MAINTENANCE', 'Under Maintenance'), ('RETIRED', 'Retired'), ('OUT_OF_SERVICE', 'Out of Service')], default='ACTIVE', max_length=16)),
59 ('current_odometer', models.IntegerField(default=0)),
60 ('image_url', models.URLField(blank=True, null=True)),
61 ('notes', models.TextField(blank=True, null=True)),
62 ],
63 options={
64 'ordering': ['-created_at'],
65 },
66 ),
67 migrations.CreateModel(
68 name='FuelCard',
69 fields=[
70 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
71 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
72 ('updated_at', models.DateTimeField(auto_now=True)),
73 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
74 ('card_number', models.CharField(max_length=32, unique=True)),
75 ('pin', models.CharField(blank=True, max_length=8, null=True)),
76 ('daily_limit', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
77 ('is_active', models.BooleanField(default=True)),
78 ('expiry_date', models.DateField(blank=True, null=True)),
79 ('driver', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fuel_cards', to='trucking.driver')),
80 ('vehicle', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fuel_cards', to='trucking.vehicle')),
81 ],
82 options={
83 'abstract': False,
84 },
85 ),
86 migrations.CreateModel(
87 name='Trip',
88 fields=[
89 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
90 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
91 ('updated_at', models.DateTimeField(auto_now=True)),
92 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
93 ('origin', models.CharField(max_length=255)),
94 ('destination', models.CharField(max_length=255)),
95 ('distance_km', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
96 ('cargo_description', models.TextField(blank=True, null=True)),
97 ('cargo_weight_tons', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
98 ('status', models.CharField(choices=[('PLANNED', 'Planned'), ('IN_PROGRESS', 'In Progress'), ('COMPLETED', 'Completed'), ('CANCELLED', 'Cancelled')], default='PLANNED', max_length=16)),
99 ('planned_departure', models.DateTimeField(blank=True, null=True)),
100 ('actual_departure', models.DateTimeField(blank=True, null=True)),
101 ('planned_arrival', models.DateTimeField(blank=True, null=True)),
102 ('actual_arrival', models.DateTimeField(blank=True, null=True)),
103 ('fuel_cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
104 ('tolls_cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
105 ('other_costs', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
106 ('notes', models.TextField(blank=True, null=True)),
107 ('driver', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trips', to='trucking.driver')),
108 ('vehicle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trips', to='trucking.vehicle')),
109 ],
110 options={
111 'ordering': ['-created_at'],
112 },
113 ),
114 migrations.CreateModel(
115 name='MaintenanceLog',
116 fields=[
117 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
118 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
119 ('updated_at', models.DateTimeField(auto_now=True)),
120 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
121 ('maintenance_type', models.CharField(choices=[('SCHEDULED', 'Scheduled Service'), ('REPAIR', 'Repair'), ('INSPECTION', 'Inspection'), ('TIRE', 'Tire Service'), ('OTHER', 'Other')], default='SCHEDULED', max_length=16)),
122 ('description', models.TextField()),
123 ('cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
124 ('vendor', models.CharField(blank=True, max_length=255, null=True)),
125 ('invoice_number', models.CharField(blank=True, max_length=64, null=True)),
126 ('next_service_odometer', models.IntegerField(blank=True, null=True)),
127 ('next_service_date', models.DateField(blank=True, null=True)),
128 ('completed_at', models.DateTimeField(blank=True, null=True)),
129 ('is_completed', models.BooleanField(default=False)),
130 ('vehicle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='maintenance_logs', to='trucking.vehicle')),
131 ],
132 options={
133 'ordering': ['-created_at'],
134 },
135 ),
136 migrations.CreateModel(
137 name='FuelLog',
138 fields=[
139 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
140 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
141 ('updated_at', models.DateTimeField(auto_now=True)),
142 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
143 ('odometer', models.IntegerField()),
144 ('liters', models.DecimalField(decimal_places=2, max_digits=10)),
145 ('price_per_liter', models.DecimalField(decimal_places=2, max_digits=10)),
146 ('total_cost', models.DecimalField(decimal_places=2, max_digits=10)),
147 ('location', models.CharField(blank=True, max_length=255, null=True)),
148 ('invoice_number', models.CharField(blank=True, max_length=64, null=True)),
149 ('notes', models.TextField(blank=True, null=True)),
150 ('driver', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fuel_logs', to='trucking.driver')),
151 ('fuel_card', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='logs', to='trucking.fuelcard')),
152 ('vehicle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='fuel_logs', to='trucking.vehicle')),
153 ],
154 options={
155 'ordering': ['-created_at'],
156 },
157 ),
158 ]