Skip to content

test(backend): notification preference defaults across migrations (#1630) - #1700

Closed
Fran6ix-coder wants to merge 1 commit into
Split-Naira:mainfrom
Fran6ix-coder:test/notification-preference-migration-defaults
Closed

Fran6ix-coder wants to merge 1 commit into
Split-Naira:mainfrom
Fran6ix-coder:test/notification-preference-migration-defaults

Conversation

@Fran6ix-coder

Copy link
Copy Markdown

Summary

Adds
otification-preference-defaults.migration.test.ts to verify notification preference defaults at the schema layer, covering new users, pre-migration existing users, migration idempotency, and upsert conflict resolution.

What is tested

Schema defaults

  • enabled column defaults to rue at the SQL level (omitting the column on INSERT gives rue)

New user — no stored rows

  • A wallet with no rows returns an empty set; the service treats absence as enabled: true
  • Inserting all five categories without specifying enabled stores rue for every one

Existing user — pre-migration rows

  • The DB accepts enabled = false for security/payment (no check constraint); enforcement lives in the service. This documents the invariant so it cannot be silently removed.
  • An optional-category opt-out (marketing = false) survives a re-run of up() — CREATE TABLE IF NOT EXISTS does not wipe rows

Migration idempotency (AddNotificationPreferences1760000000007)

  • up() called twice does not throw — DO $$ blocks absorb duplicate-object errors
  • Exactly one unique index covers (wallet, category) after a double up()
  • down() called twice does not throw — IF EXISTS guards work

Upsert conflict target

  • Plain duplicate (wallet, category) insert raises a unique-violation
  • ON CONFLICT (wallet, category) DO UPDATE converges to one row

How it runs

Requires DATABASE_URL pointing at a migrated Postgres (provided by CI). Skips locally without it; fails in CI if the env var is missing. All writes execute inside savepoints that are rolled back — nothing persists.

Closes #1630

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
split-naira Skipped Skipped Nov 24, 2026 9:17pm UTC

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Fran6ix-coder Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@SheyeJDev SheyeJDev closed this Nov 24, 2026
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.

[Backend] Test notification preference defaults across migrations

2 participants