From 21f47b91dc3c459fef55e55687b2a8a204506d96 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Wed, 15 Jul 2026 21:13:32 +0200 Subject: [PATCH] fix: add missing created_at and deleted_at columns to notification_preferences - Remove duplicate updated_at from NotificationPreference model (inherited from TimestampMixin) - Add migration 0018 to add created_at and deleted_at columns - Fixes 500 error on GET /notifications/types and /preferences --- ...18_fix_notification_preferences_columns.py | 30 +++++++++++++++++++ app/models/notification.py | 3 -- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 alembic/versions/0018_fix_notification_preferences_columns.py diff --git a/alembic/versions/0018_fix_notification_preferences_columns.py b/alembic/versions/0018_fix_notification_preferences_columns.py new file mode 100644 index 0000000..2ac32c0 --- /dev/null +++ b/alembic/versions/0018_fix_notification_preferences_columns.py @@ -0,0 +1,30 @@ +"""Fix notification_preferences table: add missing created_at and deleted_at columns. + +Revision ID: 0018 +Revises: 0017 +""" + +from alembic import op +import sqlalchemy as sa + +revision = "0018" +down_revision = "0017" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Add missing columns from TimestampMixin and SoftDeleteMixin + op.add_column( + "notification_preferences", + sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()), + ) + op.add_column( + "notification_preferences", + sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True), + ) + + +def downgrade() -> None: + op.drop_column("notification_preferences", "deleted_at") + op.drop_column("notification_preferences", "created_at") diff --git a/app/models/notification.py b/app/models/notification.py index f70f795..4869967 100644 --- a/app/models/notification.py +++ b/app/models/notification.py @@ -85,6 +85,3 @@ class NotificationPreference(Base, TenantMixin): ) type_key: Mapped[str] = mapped_column(String(20), nullable=False) is_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) - updated_at: Mapped[datetime] = mapped_column( - DateTime(timezone=True), nullable=False, server_default=func.now() - )