mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-09 01:46:46 +08:00
* fix(notifications): make preference updates atomic Co-authored-by: multica-agent <[email protected]> * fix(notifications): serialize preference mutations Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Lambda <[email protected]> Co-authored-by: multica-agent <[email protected]>
24 lines
820 B
SQL
24 lines
820 B
SQL
-- name: GetNotificationPreference :one
|
|
SELECT * FROM notification_preference
|
|
WHERE workspace_id = $1 AND user_id = $2;
|
|
|
|
-- name: UpsertNotificationPreference :one
|
|
INSERT INTO notification_preference (workspace_id, user_id, preferences)
|
|
VALUES ($1, $2, $3)
|
|
ON CONFLICT (workspace_id, user_id)
|
|
DO UPDATE SET preferences = $3, updated_at = now()
|
|
RETURNING *;
|
|
|
|
-- name: PatchNotificationPreference :one
|
|
INSERT INTO notification_preference (workspace_id, user_id, preferences)
|
|
VALUES ($1, $2, $3)
|
|
ON CONFLICT (workspace_id, user_id)
|
|
DO UPDATE SET
|
|
preferences = notification_preference.preferences || EXCLUDED.preferences,
|
|
updated_at = now()
|
|
RETURNING *;
|
|
|
|
-- name: ListNotificationPreferencesByUsers :many
|
|
SELECT * FROM notification_preference
|
|
WHERE workspace_id = $1 AND user_id = ANY(sqlc.arg('user_ids')::uuid[]);
|