diff --git a/app/models/__init__.py b/app/models/__init__.py index d8cfe8a..a5b88be 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -1 +1,3 @@ -# Models package \ No newline at end of file +from .todo import Todo + +__all__ = ["Todo"] \ No newline at end of file diff --git a/app/models/todo.py b/app/models/todo.py index 054e045..1e96ae4 100644 --- a/app/models/todo.py +++ b/app/models/todo.py @@ -1,15 +1,14 @@ -from datetime import datetime -from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime - +from sqlalchemy import Column, Integer, String, Boolean, DateTime +from sqlalchemy.sql import func from app.db.base import Base class Todo(Base): __tablename__ = "todos" - + id = Column(Integer, primary_key=True, index=True) - title = Column(String(255), nullable=False) - description = Column(Text, nullable=True) + title = Column(String, nullable=False) + description = Column(String, nullable=True) completed = Column(Boolean, default=False, nullable=False) - created_at = Column(DateTime, default=datetime.utcnow, nullable=False) - updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False) \ No newline at end of file + created_at = Column(DateTime(timezone=True), server_default=func.now()) + updated_at = Column(DateTime(timezone=True), onupdate=func.now()) \ No newline at end of file