more crap

This commit is contained in:
2025-05-26 22:25:39 -05:00
parent eb111dde14
commit 7bff7f0bd3
18 changed files with 265 additions and 225 deletions

View File

@ -1,15 +1,27 @@
from app import db
from datetime import datetime
from app import db
class GrowLog(db.Model):
__tablename__ = 'grow_logs'
id = db.Column(db.Integer, primary_key=True)
plant_id = db.Column(db.Integer, db.ForeignKey('plants.id'), nullable=False)
timestamp = db.Column(db.DateTime, default=datetime.utcnow)
event_type = db.Column(db.String(64), nullable=False)
note = db.Column(db.Text)
title = db.Column(db.String(255), nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
media = db.relationship("Media", backref="growlog", lazy=True)
updates = db.relationship('PlantUpdate', backref='grow_log', lazy=True)
class PlantUpdate(db.Model):
__tablename__ = 'plant_updates'
__table_args__ = {'extend_existing': True}
id = db.Column(db.Integer, primary_key=True)
plant_id = db.Column(db.Integer, db.ForeignKey('plants.id'), nullable=False)
growlog_id = db.Column(db.Integer, db.ForeignKey('grow_logs.id'), nullable=True)
update_type = db.Column(db.String(50), nullable=False)
description = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
media_items = db.relationship('Media', back_populates='update', lazy=True)
def __repr__(self):
return f"<GrowLog {self.event_type} @ {self.timestamp}>"