Files

46 lines
1.4 KiB
Python

"""Idea model for VoIdea."""
from typing import Optional
from sqlalchemy import Boolean, ForeignKey, String, Text
from sqlalchemy.dialects.postgresql import ARRAY, UUID
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.base import SQLBase, TimestampMixin, UUIDMixin
class Idea(SQLBase, UUIDMixin, TimestampMixin):
__tablename__ = "ideas"
user_id: Mapped[UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("users.id", ondelete="CASCADE"),
nullable=False,
index=True,
)
title: Mapped[str] = mapped_column(
String(255), nullable=False, index=True
)
content: Mapped[str] = mapped_column(
Text, nullable=False
)
status: Mapped[str] = mapped_column(
String(20), default="draft", nullable=False, index=True
)
tags: Mapped[Optional[list[str]]] = mapped_column(
ARRAY(String(50)), nullable=True
)
is_public: Mapped[bool] = mapped_column(
Boolean, default=False, nullable=False
)
public_slug: Mapped[Optional[str]] = mapped_column(
String(64), unique=True, nullable=True, index=True
)
funnel_status: Mapped[Optional[str]] = mapped_column(
String(20), nullable=True, default=None, index=True
)
FUNNEL_STATES = ["raw", "validated", "backlog", "in_progress", "launched", "retrospective"]
user = relationship("User", back_populates="ideas", lazy="selectin")