You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/05/19 18:24:01 UTC
(tooling-trusted-releases) branch sbp updated: Add a table for user notifications
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/sbp by this push:
new e3e3aa7c Add a table for user notifications
e3e3aa7c is described below
commit e3e3aa7c7a185a9704e5cb54839984581a4c38f7
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Tue May 19 19:23:39 2026 +0100
Add a table for user notifications
---
atr/models/sql.py | 20 ++++++++++++
migrations/versions/0085_2025.05.19_9d086f7e.py | 43 +++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/atr/models/sql.py b/atr/models/sql.py
index 21d1447b..4ac0eb49 100644
--- a/atr/models/sql.py
+++ b/atr/models/sql.py
@@ -160,6 +160,12 @@ class LicenseCheckMode(enum.StrEnum):
RAT = "RAT"
+class NotificationLevel(enum.StrEnum):
+ INFO = "info"
+ WARNING = "warning"
+ ERROR = "error"
+
+
class ProjectStatus(enum.StrEnum):
ACTIVE = "active"
DORMANT = "dormant"
@@ -467,6 +473,20 @@ class KeyLink(sqlmodel.SQLModel, table=True):
key_fingerprint: str = sqlmodel.Field(foreign_key="publicsigningkey.fingerprint", primary_key=True)
+# Notification:
+class Notification(sqlmodel.SQLModel, table=True):
+ id: int | None = sqlmodel.Field(default=None, primary_key=True)
+ asf_uid: str = sqlmodel.Field()
+ created: datetime.datetime = sqlmodel.Field(
+ default_factory=lambda: datetime.datetime.now(datetime.UTC),
+ sa_column=sqlalchemy.Column(UTCDateTime, nullable=False),
+ )
+ level: NotificationLevel = sqlmodel.Field(default=NotificationLevel.ERROR)
+ message: str = sqlmodel.Field()
+
+ __table_args__ = (sqlalchemy.Index("ix_notification_asf_uid_created", "asf_uid", "created"),)
+
+
# PersonalAccessToken:
class PersonalAccessToken(sqlmodel.SQLModel, table=True):
id: int | None = sqlmodel.Field(default=None, primary_key=True)
diff --git a/migrations/versions/0085_2025.05.19_9d086f7e.py b/migrations/versions/0085_2025.05.19_9d086f7e.py
new file mode 100644
index 00000000..c0be1e4f
--- /dev/null
+++ b/migrations/versions/0085_2025.05.19_9d086f7e.py
@@ -0,0 +1,43 @@
+"""Add notification table
+
+Revision ID: 0085_2025.05.19_9d086f7e
+Revises: 0084_2026.05.15_07dcce45
+Create Date: 2025-05-19 18:20:51.618305+00:00
+"""
+
+from collections.abc import Sequence
+
+import sqlalchemy as sa
+from alembic import op
+
+import atr.models.sql as sql
+
+# Revision identifiers, used by Alembic
+revision: str = "0085_2025.05.19_9d086f7e"
+down_revision: str | None = "0084_2026.05.15_07dcce45"
+branch_labels: str | Sequence[str] | None = None
+depends_on: str | Sequence[str] | None = None
+
+
+def upgrade() -> None:
+ op.create_table(
+ "notification",
+ sa.Column("id", sa.Integer(), nullable=False),
+ sa.Column("asf_uid", sa.String(), nullable=False),
+ sa.Column("created", sql.UTCDateTime(timezone=True), nullable=False),
+ sa.Column(
+ "level",
+ sa.Enum("INFO", "WARNING", "ERROR", name="notificationlevel"),
+ nullable=False,
+ ),
+ sa.Column("message", sa.String(), nullable=False),
+ sa.PrimaryKeyConstraint("id", name=op.f("pk_notification")),
+ )
+ with op.batch_alter_table("notification", schema=None) as batch_op:
+ batch_op.create_index("ix_notification_asf_uid_created", ["asf_uid", "created"], unique=False)
+
+
+def downgrade() -> None:
+ with op.batch_alter_table("notification", schema=None) as batch_op:
+ batch_op.drop_index("ix_notification_asf_uid_created")
+ op.drop_table("notification")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org