summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorLuiz Gustavo Monteiro <luizgu_mreis@hotmail.com>2025-11-04 19:18:40 -0300
committerLuiz Gustavo Monteiro <luizgu_mreis@hotmail.com>2025-11-04 19:18:40 -0300
commitc13bbb0cd30286dc515002900bb10493f2a89b09 (patch)
tree9900e7dad4ac75526fe19aedbf1351ac88d512ef /api
parente3b41c5c24488a48b552fb7aeffe250574b9c8a8 (diff)
set autoincrement on models
Diffstat (limited to 'api')
-rw-r--r--api/models.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/api/models.py b/api/models.py
index c4e16de..6b71fe1 100644
--- a/api/models.py
+++ b/api/models.py
@@ -9,7 +9,7 @@ from .database import Base
class Location(Base):
__tablename__ = "locations"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
street = Column(String(200), nullable=True, index=True)
avenue = Column(String(200), nullable=True, index=True)
zip_code = Column(String(20), nullable=True, index=True)
@@ -24,7 +24,7 @@ class Location(Base):
class Station(Base):
__tablename__ = "stations"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String(100), nullable=False, index=True)
location_id = Column(Integer, ForeignKey("locations.id"), nullable=True, index=True)
installation_date = Column(DateTime, server_default=func.now())
@@ -41,7 +41,7 @@ class Station(Base):
class SensorDevice(Base):
__tablename__ = "sensor_devices"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String(100), nullable=True, index=True)
installation_date = Column(DateTime, server_default=func.now())
station_id = Column(Integer, ForeignKey("stations.id"), nullable=True, index=True)
@@ -58,7 +58,7 @@ class SensorDevice(Base):
class Measure(Base):
__tablename__ = "measures"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String(50), nullable=True, index=True)
unit_code = Column(String(10), nullable=True)
@@ -72,7 +72,7 @@ class Measure(Base):
class Reading(Base):
__tablename__ = "readings"
- id = Column(Integer, primary_key=True, index=True)
+ id = Column(Integer, primary_key=True, index=True, autoincrement=True)
sensor_device_id = Column(Integer, ForeignKey("sensor_devices.id"), nullable=True, index=True)
measure_id = Column(Integer, ForeignKey("measures.id"), nullable=True, index=True)
value = Column(Float, nullable=True)