1
0
mirror of https://github.com/daniviga/bite.git synced 2024-12-23 08:41:24 +01:00

Convert Telemetry into an hyperscale table

This commit is contained in:
Daniele Viganò 2020-06-02 23:34:11 +02:00
parent 0031a6420a
commit 634746105a
Signed by: dani
GPG Key ID: DB49AFC03C40EE02
5 changed files with 61 additions and 14 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 3.0.6 on 2020-06-02 21:28
import api.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20200601_1523'),
]
operations = [
migrations.AlterField(
model_name='device',
name='serial',
field=models.CharField(max_length=128, unique=True, validators=[api.models.device_validation]),
),
]

View File

@ -1,13 +0,0 @@
# Generated by Django 3.0.6 on 2020-06-01 17:10
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('telemetry', '0002_auto_20200601_1557'),
]
operations = [
]

View File

@ -0,0 +1,26 @@
# Generated by Django 3.0.6 on 2020-06-02 21:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('telemetry', '0002_auto_20200601_1557'),
]
operations = [
migrations.AlterModelOptions(
name='telemetry',
options={'ordering': ['time', 'device'], 'verbose_name_plural': 'Telemetry'},
),
migrations.RemoveField(
model_name='telemetry',
name='id',
),
migrations.AlterField(
model_name='telemetry',
name='time',
field=models.DateTimeField(auto_now_add=True, primary_key=True, serialize=False),
),
]

View File

@ -0,0 +1,15 @@
# Generated by Django 3.0.6 on 2020-06-02 21:32
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('telemetry', '0003_auto_20200602_2131'),
]
operations = [
migrations.RunSQL(
"SELECT create_hypertable('telemetry_telemetry', 'time');"),
]

View File

@ -6,7 +6,7 @@ from api.models import Device
class Telemetry(models.Model):
device = models.ForeignKey(Device, on_delete=models.CASCADE)
time = models.DateTimeField(auto_now_add=True)
time = models.DateTimeField(primary_key=True, auto_now_add=True)
payload = JSONField()
class Meta: