added puck events

This commit is contained in:
GotthardG
2024-12-11 13:57:23 +01:00
parent 66a0ce3281
commit 958c9167fc
3 changed files with 67 additions and 16 deletions

View File

@ -1,8 +1,7 @@
from sqlalchemy import Column, Integer, String, Date, ForeignKey, JSON, Interval, DateTime, Boolean
from sqlalchemy import Column, Integer, String, Date, ForeignKey, JSON, DateTime, Boolean
from sqlalchemy.orm import relationship
from .database import Base
from datetime import datetime, timedelta
import uuid
from datetime import datetime
class Shipment(Base):
@ -118,6 +117,7 @@ class Puck(Base):
dewar_id = Column(Integer, ForeignKey('dewars.id'))
dewar = relationship("Dewar", back_populates="pucks")
samples = relationship("Sample", back_populates="puck")
events = relationship("PuckEvent", back_populates="puck")
class Sample(Base):
@ -168,13 +168,13 @@ class SampleEvent(Base):
sample = relationship("Sample", back_populates="events")
#class PuckEvent(Base):
# __tablename__ = "sample_events"
#
# id = Column(Integer, primary_key=True, index=True)
# puck_id = Column(Integer, ForeignKey('puck.id'))
# tell_position = Column(String(255), nullable=True)
# event_type = Column(String(255), index=True)
# timestamp = Column(DateTime, default=datetime.utcnow)
#
# sample = relationship("Sample", back_populates="events")
class PuckEvent(Base):
__tablename__ = "puck_events"
id = Column(Integer, primary_key=True, index=True)
puck_id = Column(Integer, ForeignKey('pucks.id'))
tell_position = Column(String(255), nullable=True)
event_type = Column(String(255), index=True)
timestamp = Column(DateTime, default=datetime.utcnow)
puck = relationship("Puck", back_populates="events")