Skip to content

Commit

Permalink
Fix 4252
Browse files Browse the repository at this point in the history
  • Loading branch information
haneslinger committed Jan 5, 2024
1 parent 2f24661 commit 87816d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ django-braces==1.14.0
django-oauth-toolkit==1.2.0

future==0.18.3

# db
django-timescaledb
23 changes: 23 additions & 0 deletions seed/migrations/0211_auto_20240105_1306.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.23 on 2024-01-05 21:06

import timescale.db.models.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('seed', '0210_natural_sort'),
]

operations = [
migrations.AlterField(
model_name='sensorreading',
name='timestamp',
field=timescale.db.models.fields.TimescaleDateTimeField(interval='1 second'),
),
migrations.AlterUniqueTogether(
name='sensor',
unique_together={('data_logger', 'column_name'), ('data_logger', 'display_name')},
),
]
9 changes: 6 additions & 3 deletions seed/models/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
See also https://github.com/seed-platform/seed/main/LICENSE.md
"""
from django.db import models
from timescale.db.models.fields import TimescaleDateTimeField

from seed.models import Property

Expand Down Expand Up @@ -44,13 +45,15 @@ class Sensor(models.Model):
column_name = models.CharField(max_length=255)

class Meta:
unique_together = ('data_logger', 'display_name')
unique_together = ('data_logger', 'column_name')
unique_together = (
('data_logger', 'display_name'),
('data_logger', 'column_name'),
)


class SensorReading(models.Model):
reading = models.FloatField(null=True)
timestamp = models.DateTimeField()
timestamp = TimescaleDateTimeField(interval="1 second")
sensor = models.ForeignKey(
Sensor,
on_delete=models.CASCADE,
Expand Down

0 comments on commit 87816d6

Please sign in to comment.