
- Set up SQLite database configuration and directory structure - Configure Alembic for proper SQLite migrations - Add initial model schemas and API endpoints - Fix OAuth2 authentication - Implement proper code formatting with Ruff
26 lines
927 B
Python
26 lines
927 B
Python
from sqlalchemy import Column, Integer, String, Float, ForeignKey, DateTime, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class Location(Base):
|
|
"""Location model for storing locations and their weather data."""
|
|
|
|
__tablename__ = "locations"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, index=True, nullable=False)
|
|
latitude = Column(Float, nullable=False)
|
|
longitude = Column(Float, nullable=False)
|
|
country = Column(String, nullable=True)
|
|
is_default = Column(Boolean, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# Foreign keys
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="locations") |