corvix.db ========= .. py:module:: corvix.db .. autoapi-nested-parse:: SQLAlchemy ORM models and engine helpers for PostgreSQL persistence. Classes ------- .. autoapisummary:: corvix.db.Base corvix.db.User corvix.db.NotificationRecordRow corvix.db.UserPreferences corvix.db.PushSubscription Functions --------- .. autoapisummary:: corvix.db.get_database_url Module Contents --------------- .. py:class:: Base Bases: :py:obj:`sqlalchemy.orm.DeclarativeBase` Shared declarative base for all ORM models. .. py:class:: User Bases: :py:obj:`Base` Registered user with an encrypted GitHub token. .. py:attribute:: __tablename__ :value: 'users' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[uuid.UUID] .. py:attribute:: github_login :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: github_token :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: created_at :type: sqlalchemy.orm.Mapped[datetime.datetime] .. py:attribute:: updated_at :type: sqlalchemy.orm.Mapped[datetime.datetime] .. py:attribute:: preferences :type: sqlalchemy.orm.Mapped[UserPreferences | None] .. py:attribute:: push_subscriptions :type: sqlalchemy.orm.Mapped[list[PushSubscription]] .. py:attribute:: notification_records :type: sqlalchemy.orm.Mapped[list[NotificationRecordRow]] .. py:class:: NotificationRecordRow Bases: :py:obj:`Base` Persisted notification record scoped to a user. .. py:attribute:: __tablename__ :value: 'notification_records' .. py:attribute:: __table_args__ .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] .. py:attribute:: user_id :type: sqlalchemy.orm.Mapped[uuid.UUID] .. py:attribute:: account_id :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: account_label :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: thread_id :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: repository :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: reason :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: subject_title :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: subject_type :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: unread :type: sqlalchemy.orm.Mapped[bool] .. py:attribute:: updated_at :type: sqlalchemy.orm.Mapped[datetime.datetime] .. py:attribute:: thread_url :type: sqlalchemy.orm.Mapped[str | None] .. py:attribute:: web_url :type: sqlalchemy.orm.Mapped[str | None] .. py:attribute:: score :type: sqlalchemy.orm.Mapped[float] .. py:attribute:: excluded :type: sqlalchemy.orm.Mapped[bool] .. py:attribute:: matched_rules :type: sqlalchemy.orm.Mapped[list[str]] .. py:attribute:: actions_taken :type: sqlalchemy.orm.Mapped[list[str]] .. py:attribute:: context :type: sqlalchemy.orm.Mapped[dict[str, object]] .. py:attribute:: dismissed :type: sqlalchemy.orm.Mapped[bool] .. py:attribute:: snapshot_at :type: sqlalchemy.orm.Mapped[datetime.datetime] .. py:attribute:: user :type: sqlalchemy.orm.Mapped[User] .. py:class:: UserPreferences Bases: :py:obj:`Base` Per-user preferences (theme, browser notifications). .. py:attribute:: __tablename__ :value: 'user_preferences' .. py:attribute:: user_id :type: sqlalchemy.orm.Mapped[uuid.UUID] .. py:attribute:: theme :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: browser_notify :type: sqlalchemy.orm.Mapped[bool] .. py:attribute:: user :type: sqlalchemy.orm.Mapped[User] .. py:class:: PushSubscription Bases: :py:obj:`Base` Browser push subscription for a user. .. py:attribute:: __tablename__ :value: 'push_subscriptions' .. py:attribute:: __table_args__ .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] .. py:attribute:: user_id :type: sqlalchemy.orm.Mapped[uuid.UUID] .. py:attribute:: endpoint :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: p256dh_key :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: auth_key :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: created_at :type: sqlalchemy.orm.Mapped[datetime.datetime] .. py:attribute:: user :type: sqlalchemy.orm.Mapped[User] .. py:function:: get_database_url(url_env: str = 'DATABASE_URL') -> str | None Return DB URL from env, supporting `${URL_ENV}_FILE` Docker secret files.