feat(db): add newsletter schema #68

Merged
addison merged 3 commits from exe-dev-bot/market:feat/newsletter-schema into main 2026-02-05 05:43:31 -05:00
Contributor

Summary

Adds the database schema for the weekly newsletter feature (spec-003).

Changes

  • Add newsletter_enabled boolean column to contact_info table
  • Create newsletter table for storing generated newsletters
  • Create newsletter_send_log table for tracking email sends
  • Create announcement table for admin announcements
  • Add RLS policies (owner-only for newsletters, authenticated for announcements)
  • Add indexes for performance
  • Rename 10_indexes.sql to 99_indexes.sql so it runs after all tables
  • Regenerate TypeScript types
  • Add SET search_path = public to SECURITY DEFINER functions in connections schema

New Tables

Table Purpose
newsletter Stores generated newsletters per user (id, user_id, created_at, content_json)
newsletter_send_log Tracks email sends (newsletter_id, contact_info_id, sent_at, status, error_message)
announcement Admin announcements for newsletters (id, content_html, publish_date, created_at)

Testing

  • just db-reset applies cleanly
  • New tables visible in Supabase Studio (http://localhost:54323) under Table Editor
  • contact_info table has newsletter_enabled boolean column (default: false)
  • RLS policies visible under Authentication > Policies for newsletter, newsletter_send_log, announcement

Spec Progress

Completes the Database Schema section of spec-003 (9/9 tasks).

## Summary Adds the database schema for the weekly newsletter feature (spec-003). ## Changes - Add `newsletter_enabled` boolean column to `contact_info` table - Create `newsletter` table for storing generated newsletters - Create `newsletter_send_log` table for tracking email sends - Create `announcement` table for admin announcements - Add RLS policies (owner-only for newsletters, authenticated for announcements) - Add indexes for performance - Rename `10_indexes.sql` to `99_indexes.sql` so it runs after all tables - Regenerate TypeScript types - Add `SET search_path = public` to SECURITY DEFINER functions in connections schema ## New Tables | Table | Purpose | |-------|--------| | `newsletter` | Stores generated newsletters per user (id, user_id, created_at, content_json) | | `newsletter_send_log` | Tracks email sends (newsletter_id, contact_info_id, sent_at, status, error_message) | | `announcement` | Admin announcements for newsletters (id, content_html, publish_date, created_at) | ## Testing - [x] `just db-reset` applies cleanly - [x] New tables visible in Supabase Studio (http://localhost:54323) under Table Editor - [x] `contact_info` table has `newsletter_enabled` boolean column (default: false) - [x] RLS policies visible under Authentication > Policies for newsletter, newsletter_send_log, announcement ## Spec Progress Completes the **Database Schema** section of spec-003 (9/9 tasks).
feat(db): add newsletter schema
Some checks failed
CI / Unit Tests (pull_request) Successful in 1m49s
CI / Lint, Type Check & Format (pull_request) Successful in 2m8s
CI / E2E Tests (pull_request) Failing after 3m24s
25c2b8c42f
- Add newsletter_enabled boolean to contact_info table
- Create newsletter table for storing generated newsletters
- Create newsletter_send_log table for tracking email sends
- Create announcement table for admin announcements
- Add RLS policies (owner-only for newsletters, authenticated for announcements)
- Add indexes for performance
- Rename 10_indexes.sql to 99_indexes.sql so it runs after all tables
- Regenerate TypeScript types

Co-authored-by: Shelley <shelley@exe.dev>
fix: add search_path to SECURITY DEFINER functions
Some checks failed
CI / Unit Tests (pull_request) Successful in 1m48s
CI / Lint, Type Check & Format (pull_request) Successful in 2m2s
CI / E2E Tests (pull_request) Failing after 4m11s
9b60f162b7
- Update connection functions in schema to include SET search_path = public
- Remove redundant function definitions from newsletter migration
- Prevents future migrations from regenerating unchanged functions

Co-authored-by: Shelley <shelley@exe.dev>
docs: add database schema best practices to AGENTS.md
Some checks failed
CI / Unit Tests (pull_request) Successful in 1m24s
CI / Lint, Type Check & Format (pull_request) Failing after 1m49s
CI / E2E Tests (pull_request) Failing after 3m54s
df9f631c64
- Schema file ordering (99_indexes.sql runs last)
- SECURITY DEFINER functions need SET search_path
- Review generated migrations for redundant changes
- PR testing sections should use Supabase Studio, not psql

Co-authored-by: Shelley <shelley@exe.dev>
exe-dev-bot force-pushed feat/newsletter-schema from df9f631c64
Some checks failed
CI / Unit Tests (pull_request) Successful in 1m24s
CI / Lint, Type Check & Format (pull_request) Failing after 1m49s
CI / E2E Tests (pull_request) Failing after 3m54s
to b9554ce7d9
Some checks failed
CI / Unit Tests (pull_request) Successful in 1m57s
CI / Lint, Type Check & Format (pull_request) Successful in 2m10s
CI / E2E Tests (pull_request) Failing after 3m39s
2026-02-05 05:39:21 -05:00
Compare
addison deleted branch feat/newsletter-schema 2026-02-05 05:43:31 -05:00
addison referenced this pull request from a commit 2026-02-05 05:43:32 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kwila/market!68
No description provided.