From c13bbb0cd30286dc515002900bb10493f2a89b09 Mon Sep 17 00:00:00 2001 From: Luiz Gustavo Monteiro Date: Tue, 4 Nov 2025 19:18:40 -0300 Subject: set autoincrement on models --- api/models.py | 10 +++++----- 1 file 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) -- cgit v1.2.3