Skip to content

Conversation

@youngkidwarrior
Copy link
Collaborator

Summary

Create database schema for the notifications system with notifications and push_tokens tables, RLS policies, and PgTAP tests.

Changes

  • Add notification_type enum: transfer_sent, transfer_received, tag_confirmed, account_activity, system
  • Add push_token_platform enum: expo, web
  • Create notifications table for storing user notifications
  • Create push_tokens table for storing push notification tokens (Expo and Web Push)
  • Add RLS policies allowing users to manage only their own rows
  • Add update_push_token_updated_at trigger for automatic timestamp updates
  • Add indexes for efficient querying by user_id and read status
  • Add unique constraints to prevent duplicate tokens
  • Add 15 PgTAP tests for table operations and RLS enforcement

Tables

notifications

Column Type Description
id bigint Auto-increment primary key
user_id uuid Foreign key to auth.users (CASCADE delete)
type notification_type Type of notification
title text Notification title
body text Notification body
data jsonb Optional JSON data
read boolean Read status (default false)
created_at timestamptz Creation timestamp

push_tokens

Column Type Description
id bigint Auto-increment primary key
user_id uuid Foreign key to auth.users (CASCADE delete)
platform push_token_platform expo or web
token text Expo push token
endpoint text Web Push endpoint URL
p256dh text Web Push public key
auth text Web Push auth secret
created_at timestamptz Creation timestamp
updated_at timestamptz Auto-updated on changes

Testing

  • All 674 tests pass including 15 new notifications tests
  • Tests cover CRUD operations and RLS enforcement for both tables

This PR was generated with Warp.

Victor Ginelli and others added 2 commits December 31, 2025 14:42
Create database schema for notifications system:
- Add notification_type enum: transfer_sent, transfer_received, tag_confirmed, account_activity, system
- Add push_token_platform enum: expo, web
- Create notifications table with id, user_id, type, title, body, data jsonb, read, created_at
- Create push_tokens table with id, user_id, platform, token, endpoint, p256dh, auth, created_at, updated_at
- Add RLS policies for user-owned rows (select, insert, update, delete)
- Add update_push_token_updated_at trigger for automatic timestamp updates
- Add indexes for efficient querying by user_id
- Add unique constraints to prevent duplicate tokens
- Add PgTAP tests for table operations and RLS enforcement

Co-Authored-By: Warp <agent@warp.dev>
Co-Authored-By: Warp <agent@warp.dev>
@github-actions
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants