Skip to content

Feat/newsletter indexes#574

Merged
hman38705 merged 3 commits intosolutions-plug:mainfrom
famvilianity-eng:feat/newsletter-indexes
Apr 24, 2026
Merged

Feat/newsletter indexes#574
hman38705 merged 3 commits intosolutions-plug:mainfrom
famvilianity-eng:feat/newsletter-indexes

Conversation

@famvilianity-eng
Copy link
Copy Markdown
Contributor

Summary

I've successfully implemented all three issues and created separate commits for each. Here's what was done:

✅ Issue #551: Database Indexes for Newsletter Queries

  • Created migration 009_add_newsletter_indexes.sql
  • Added composite index on (confirmed, unsubscribed_at) for status filtering
  • Added composite index on (email, confirmed) for email lookups
  • Used CONCURRENTLY to avoid locking during index creation

✅ Issue #552: Soft Delete for Newsletter Subscribers

  • Created migration 010_add_soft_delete_newsletter.sql with deleted_at column
  • Updated NewsletterSubscriber struct to include deleted_at field
  • Modified newsletter_get_by_email() to exclude soft-deleted records
  • Added new newsletter_soft_delete() method for GDPR compliance
  • Kept newsletter_gdpr_delete() for permanent hard deletion

✅ Issue #557: Contract Storage Migration Utilities

  • Created contracts/predict-iq/src/modules/migration.rs with:
    • execute_migration() with automatic rollback
    • backup_storage_state() and restore_storage_state()
    • verify_migration_integrity() for data validation
    • reverse_migration() for reverting changes
    • Comprehensive tests

Closes #551
Closes #552
Closes #557

…ber queries

- Add composite index on (confirmed, unsubscribed_at) for status filtering
- Add composite index on (email, confirmed) for email lookups with status
- Use CONCURRENTLY to avoid locking during index creation
- Filter indexes to exclude unsubscribed records for better selectivity

Improves query performance as subscriber count grows.
…ibers

- Add deleted_at timestamp column to newsletter_subscribers table
- Create indexes on deleted_at and active records for query optimization
- Update newsletter_get_by_email to exclude soft-deleted records
- Update newsletter_unsubscribe to check deleted_at condition
- Add newsletter_soft_delete method for GDPR compliance
- Keep hard delete (newsletter_gdpr_delete) for permanent removal

Enables audit trails and GDPR compliance without data loss.
- Implement execute_migration with automatic rollback on failure
- Add backup/restore functionality for storage state
- Record migration history with version tracking
- Implement verify_migration_integrity to check critical keys
- Add reverse_migration for reverting to previous versions
- Include comprehensive tests for migration scenarios

Enables safe contract upgrades with data integrity verification.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 24, 2026

@famvilianity-eng 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

@hman38705 hman38705 merged commit d849eef into solutions-plug:main Apr 24, 2026
2 of 13 checks passed
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.

Add contract storage migration utilities Implement soft delete for newsletter subscribers Add database index for newsletter subscriber queries

2 participants