Spaces:
Sleeping
Sleeping
| from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Text | |
| from sqlalchemy.dialects.postgresql import JSONB | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.sql import func | |
| from .database import Base | |
| class User(Base): | |
| __tablename__ = "users" | |
| id = Column(Integer, primary_key=True, index=True) | |
| google_id = Column(String, unique=True, index=True, nullable=False) | |
| email = Column(String, unique=True, index=True, nullable=False) | |
| full_name = Column(String, nullable=True) | |
| profile_picture = Column(String, nullable=True) | |
| created_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| projects = relationship("Project", back_populates="owner") | |
| class Project(Base): | |
| __tablename__ = "projects" | |
| id = Column(Integer, primary_key=True, index=True) | |
| user_id = Column(Integer, ForeignKey("users.id")) | |
| title = Column(String, nullable=False) | |
| description = Column(Text, nullable=True) | |
| # Using JSONB for Postgres, but if fallback to SQLite is needed, we might need a custom type or just Text. | |
| # For now, we assume Postgres as requested. | |
| artifacts = Column(JSONB, nullable=False) | |
| created_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| updated_at = Column(DateTime(timezone=True), onupdate=func.now()) | |
| owner = relationship("User", back_populates="projects") | |