mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-10-02 23:45:08 -04:00
feat: add Notifications table for push token registration refs #4684
Add Notifications table to fresh-install schema (zm_create.sql.in) and create idempotent migration (zm_update-1.39.2.sql) for existing installs. The table stores FCM push notification tokens so zm_detect can send push notifications directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ca0e03885
commit
2fce145a90
2 files changed
+48
No files matched your search
@@ -1329,6 +1329,24 @@ CREATE TABLE `Events_Tags` (
|
||||
CONSTRAINT `Events_Tags_ibfk_2` FOREIGN KEY (`EventId`) REFERENCES `Events` (`Id`) ON DELETE CASCADE
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
CREATE TABLE `Notifications` (
|
||||
`Id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`UserId` int unsigned NOT NULL,
|
||||
`Token` varchar(512) NOT NULL,
|
||||
`Platform` enum('android','ios','web') NOT NULL,
|
||||
`MonitorList` text DEFAULT NULL,
|
||||
`Interval` int unsigned NOT NULL DEFAULT 0,
|
||||
`PushState` enum('enabled','disabled') NOT NULL DEFAULT 'enabled',
|
||||
`AppVersion` varchar(32) DEFAULT NULL,
|
||||
`BadgeCount` int NOT NULL DEFAULT 0,
|
||||
`LastNotifiedAt` datetime DEFAULT NULL,
|
||||
`CreatedOn` datetime DEFAULT NULL,
|
||||
`UpdatedOn` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `Notifications_Token_idx` (`Token`),
|
||||
KEY `Notifications_UserId_idx` (`UserId`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
source @PKGDATADIR@/db/Object_Types.sql
|
||||
-- We generally don't alter triggers, we drop and re-create them, so let's keep them in a separate file that we can just source in update scripts.
|
||||
source @PKGDATADIR@/db/triggers.sql
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--
|
||||
-- Add Notifications table for FCM push token registration
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'Notifications'
|
||||
AND table_schema = DATABASE()) > 0,
|
||||
"SELECT 'Notifications table already exists'",
|
||||
"CREATE TABLE `Notifications` (
|
||||
`Id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`UserId` int unsigned NOT NULL,
|
||||
`Token` varchar(512) NOT NULL,
|
||||
`Platform` enum('android','ios','web') NOT NULL,
|
||||
`MonitorList` text DEFAULT NULL,
|
||||
`Interval` int unsigned NOT NULL DEFAULT 0,
|
||||
`PushState` enum('enabled','disabled') NOT NULL DEFAULT 'enabled',
|
||||
`AppVersion` varchar(32) DEFAULT NULL,
|
||||
`BadgeCount` int NOT NULL DEFAULT 0,
|
||||
`LastNotifiedAt` datetime DEFAULT NULL,
|
||||
`CreatedOn` datetime DEFAULT NULL,
|
||||
`UpdatedOn` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `Notifications_Token_idx` (`Token`),
|
||||
KEY `Notifications_UserId_idx` (`UserId`)
|
||||
) ENGINE=InnoDB"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in new issue
Block a user