From 80f5893d92ca916a2afd81fd2937dcf55d6cae16 Mon Sep 17 00:00:00 2001 From: Agent Date: Sat, 13 Jun 2026 11:57:56 -0400 Subject: [PATCH] refactor: drop is_read and read_at from notifications table - is_read and read_at columns are now obsolete since notification_reads tracks per-user read receipts - Removed UPDATE statements in markAsRead/markAllAsRead that touched the old columns - API response still includes computed is_read field via SQL CASE in getForUser() JOIN with notification_reads, maintaining Android compatibility - Migration 009 drops both columns --- .../009_remove_notification_obsolete_columns.sql | 3 +++ src/Models/Notification.php | 14 -------------- 2 files changed, 3 insertions(+), 14 deletions(-) create mode 100644 database/migrations/009_remove_notification_obsolete_columns.sql diff --git a/database/migrations/009_remove_notification_obsolete_columns.sql b/database/migrations/009_remove_notification_obsolete_columns.sql new file mode 100644 index 0000000..286310e --- /dev/null +++ b/database/migrations/009_remove_notification_obsolete_columns.sql @@ -0,0 +1,3 @@ +ALTER TABLE `notifications` + DROP COLUMN `is_read`, + DROP COLUMN `read_at`; diff --git a/src/Models/Notification.php b/src/Models/Notification.php index 6b0b7ff..b7993f9 100644 --- a/src/Models/Notification.php +++ b/src/Models/Notification.php @@ -86,13 +86,6 @@ class Notification } catch (\Throwable $e) { // Already read, ignore } - - $this->db->update( - 'notifications', - ['is_read' => 1, 'read_at' => date('Y-m-d H:i:s')], - 'id = ? AND (user_id IS NULL OR user_id = ?)', - [$id, $userId] - ); } public function markAllAsRead(int $userId): void @@ -119,13 +112,6 @@ class Notification // Duplicate entry — already read, skip } } - - $this->db->update( - 'notifications', - ['is_read' => 1, 'read_at' => $now], - '(user_id IS NULL OR user_id = ?) AND is_read = 0', - [$userId] - ); } public function getAll(int $page = 1, int $perPage = 20): array