diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-11-04 20:29:15 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-11-04 20:29:15 -0300 |
| commit | b49e9024a5bb595701b5300772b55b703b6b7856 (patch) | |
| tree | 645a2fc309a0e81dc071cacc64ed302619771412 /api/models.py | |
| parent | 48ffb49e0913dc7a94c3bdfb0c0cf69e4b8f0235 (diff) | |
| parent | a86fa3cf1e041e30ab0bae7dc6074087349dd226 (diff) | |
Merge branch 'master' of https://github.com/Simplesmente-O-Grupo/iot-monitoring
Diffstat (limited to 'api/models.py')
| -rw-r--r-- | api/models.py | 10 |
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) |
