Календарь: напоминания личными уведомлениями и тёмная тема
This commit is contained in:
@@ -418,11 +418,14 @@ CREATE TABLE IF NOT EXISTS notifications (
|
||||
target JSONB,
|
||||
admin_only BOOLEAN NOT NULL DEFAULT false,
|
||||
branch_id INT REFERENCES branches(id) ON DELETE SET NULL,
|
||||
user_id INT REFERENCES users(id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
ALTER TABLE notifications ADD COLUMN IF NOT EXISTS user_id INT REFERENCES users(id) ON DELETE CASCADE;
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_created_at ON notifications(created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_branch_id ON notifications(branch_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_id ON notifications(user_id) WHERE user_id IS NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS notification_reads (
|
||||
user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
@@ -982,6 +985,7 @@ INSERT INTO settings (key, value) VALUES ('notify_face_recognized', 'true') ON C
|
||||
INSERT INTO settings (key, value) VALUES ('notify_face_scan_error', 'true') ON CONFLICT (key) DO NOTHING;
|
||||
INSERT INTO settings (key, value) VALUES ('notify_chat_message', 'true') ON CONFLICT (key) DO NOTHING;
|
||||
INSERT INTO settings (key, value) VALUES ('notify_photo_broken_link', 'true') ON CONFLICT (key) DO NOTHING;
|
||||
INSERT INTO settings (key, value) VALUES ('notify_calendar_reminder', 'true') ON CONFLICT (key) DO NOTHING;
|
||||
INSERT INTO settings (key, value) VALUES ('faces_broken_scan_enabled', 'true') ON CONFLICT (key) DO NOTHING;
|
||||
INSERT INTO settings (key, value) VALUES ('faces_broken_scan_interval_hours', '6') ON CONFLICT (key) DO NOTHING;
|
||||
|
||||
@@ -1164,3 +1168,14 @@ ALTER TABLE calendar_events ADD COLUMN IF NOT EXISTS is_common BOOLEAN NOT NULL
|
||||
CREATE INDEX IF NOT EXISTS idx_calendar_events_user_start ON calendar_events(user_id, starts_at) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_calendar_events_common_start ON calendar_events(starts_at) WHERE deleted_at IS NULL AND is_common;
|
||||
CREATE INDEX IF NOT EXISTS idx_calendar_events_purge ON calendar_events(purge_at) WHERE purge_at IS NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS calendar_reminder_sent (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
event_id INT NOT NULL REFERENCES calendar_events(id) ON DELETE CASCADE,
|
||||
user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
occurrence_at TIMESTAMPTZ NOT NULL,
|
||||
minutes INT NOT NULL,
|
||||
sent_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (event_id, user_id, occurrence_at, minutes)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_calendar_reminder_sent_sent_at ON calendar_reminder_sent(sent_at);
|
||||
|
||||
Reference in New Issue
Block a user