fix: Switches DecimalFields to FloatFields in GPSPoint
Converts battery, accuracy, speed, and bearing fields from DecimalField to FloatField in GPSPoint model for improved performance and simplified operations. Updates migration to reflect these changes, ensuring consistency across the database.
This commit is contained in:
parent
4de1c966d6
commit
a6025dee31
2 changed files with 76 additions and 34 deletions
|
@ -1,10 +1,10 @@
|
|||
# Generated by Django 4.1.1 on 2022-09-09 16:07
|
||||
# Generated by Django 5.0.6 on 2024-11-18 05:40
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.gis.db.models.fields
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -17,38 +17,84 @@ class Migration(migrations.Migration):
|
|||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='GPSTrack',
|
||||
name="GPSTrack",
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, primary_key=True, serialize=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"user",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GPSToken',
|
||||
name="GPSToken",
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(blank=True, max_length=128, null=True)),
|
||||
('token', models.UUIDField(default=uuid.uuid4)),
|
||||
('read', models.BooleanField(default=False)),
|
||||
('write', models.BooleanField(default=False)),
|
||||
('history', models.BooleanField(default=False)),
|
||||
('track', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gpslog.gpstrack')),
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("name", models.CharField(blank=True, max_length=128, null=True)),
|
||||
("token", models.UUIDField(default=uuid.uuid4)),
|
||||
("read", models.BooleanField(default=False)),
|
||||
("write", models.BooleanField(default=False)),
|
||||
("history", models.BooleanField(default=False)),
|
||||
(
|
||||
"track",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="gpslog.gpstrack",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GPSPoint',
|
||||
name="GPSPoint",
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('point', django.contrib.gis.db.models.fields.PointField(srid=4326)),
|
||||
('timestamp', models.DateTimeField()),
|
||||
('battery', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True)),
|
||||
('accuracy', models.DecimalField(blank=True, decimal_places=32, max_digits=64, null=True)),
|
||||
('speed', models.DecimalField(blank=True, decimal_places=32, max_digits=64, null=True)),
|
||||
('bearing', models.DecimalField(blank=True, decimal_places=61, max_digits=64, null=True)),
|
||||
('satellites', models.IntegerField(blank=True, null=True)),
|
||||
('user_agent', models.TextField(blank=True, null=True)),
|
||||
('token', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='gpslog.gpstoken')),
|
||||
('track', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gpslog.gpstrack')),
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("point", django.contrib.gis.db.models.fields.PointField(srid=4326)),
|
||||
("timestamp", models.DateTimeField()),
|
||||
("battery", models.FloatField(blank=True, null=True)),
|
||||
("accuracy", models.FloatField(blank=True, null=True)),
|
||||
("speed", models.FloatField(blank=True, null=True)),
|
||||
("bearing", models.FloatField(blank=True, null=True)),
|
||||
("satellites", models.IntegerField(blank=True, null=True)),
|
||||
("user_agent", models.TextField(blank=True, null=True)),
|
||||
(
|
||||
"token",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
to="gpslog.gpstoken",
|
||||
),
|
||||
),
|
||||
(
|
||||
"track",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="gpslog.gpstrack",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -27,13 +27,9 @@ class GPSPoint(models.Model):
|
|||
token = models.ForeignKey(GPSToken, models.SET_NULL, null=True)
|
||||
|
||||
# Optional additional information
|
||||
battery = models.DecimalField(
|
||||
max_digits=5, decimal_places=2, null=True, blank=True)
|
||||
accuracy = models.DecimalField(
|
||||
max_digits=64, decimal_places=32, null=True, blank=True)
|
||||
speed = models.DecimalField(
|
||||
max_digits=64, decimal_places=32, null=True, blank=True)
|
||||
bearing = models.DecimalField(
|
||||
max_digits=64, decimal_places=61, null=True, blank=True)
|
||||
battery = models.FloatField(null=True, blank=True)
|
||||
accuracy = models.FloatField(null=True, blank=True)
|
||||
speed = models.FloatField(null=True, blank=True)
|
||||
bearing = models.FloatField(null=True, blank=True)
|
||||
satellites = models.IntegerField(null=True, blank=True)
|
||||
user_agent = models.TextField(null=True, blank=True)
|
||||
|
|
Loading…
Reference in a new issue