my-favs/backend/app/models.py
RamonCalvo aea7bf5ada feat: add bookmarks CRUD API with FastAPI and Docker Compose
REST API for managing personal bookmarks (title, link, category).
PostgreSQL database with async SQLAlchemy, containerized with Docker Compose.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 18:37:23 -06:00

21 lines
680 B
Python

import uuid
from sqlalchemy import DateTime, String, func
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
class Bookmark(Base):
__tablename__ = "bookmarks"
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
)
title: Mapped[str] = mapped_column(String(500), nullable=False)
link: Mapped[str] = mapped_column(String(2000), nullable=False)
category: Mapped[str | None] = mapped_column(String(100), nullable=True)
created_at = mapped_column(DateTime(timezone=True), server_default=func.now())