backend/src/features/email-ingestion/migrations/001_create_email_ingestion_tables.sql -- email_ingestion_queue (UUID PK, UNIQUE email_id, status CHECK, JSONB processing_result, retry_count) and pending_vehicle_associations (UUID PK, record_type CHECK, documents FK with ON DELETE SET NULL, status CHECK) with indexes and triggers
backend/src/features/email-ingestion/migrations/002_create_email_templates.sql -- Extended email_templates CHECK constraint with 3 new keys; seeded receipt_processed, receipt_failed, receipt_pending_vehicle templates with full HTML bodies and ON CONFLICT upsert
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Relates to #149
Scope
Create the database migrations and TypeScript types for the email ingestion feature.
Database Tables
email_ingestion_queue: id, email_id (UNIQUE), sender_email, user_id, received_at, subject, status (pending/processing/completed/failed), processing_result JSONB, error_message, retry_count, created_at, updated_atpending_vehicle_associations: id, user_id, record_type (fuel_log/maintenance_record), extracted_data JSONB, document_id (FK documents), status (pending/resolved/expired), created_at, resolved_atEmail Templates (seed data)
receipt_processed: Confirmation when email receipt is successfully processedreceipt_failed: Error notification when processing failsreceipt_pending_vehicle: Notification when multi-vehicle user needs to select vehicleTypeScript Types
EmailIngestionQueueRecord,PendingVehicleAssociationEmailIngestionStatus,PendingAssociationStatusemail.receivedeventFiles
backend/src/features/email-ingestion/migrations/001_create_email_ingestion_tables.sqlbackend/src/features/email-ingestion/migrations/002_create_email_templates.sqlbackend/src/features/email-ingestion/domain/email-ingestion.types.tsAcceptance Criteria
Milestone: Email Ingestion Database Schema and Types
Phase: Execution | Agent: Developer | Status: PASS
Completed
backend/src/features/email-ingestion/migrations/001_create_email_ingestion_tables.sql-- email_ingestion_queue (UUID PK, UNIQUE email_id, status CHECK, JSONB processing_result, retry_count) and pending_vehicle_associations (UUID PK, record_type CHECK, documents FK with ON DELETE SET NULL, status CHECK) with indexes and triggersbackend/src/features/email-ingestion/migrations/002_create_email_templates.sql-- Extended email_templates CHECK constraint with 3 new keys; seeded receipt_processed, receipt_failed, receipt_pending_vehicle templates with full HTML bodies and ON CONFLICT upsertbackend/src/features/email-ingestion/domain/email-ingestion.types.ts-- EmailIngestionQueueRecord, PendingVehicleAssociation interfaces; EmailIngestionStatus, PendingAssociationStatus, EmailRecordType enums; Resend webhook payload types (ResendWebhookEvent, ResendWebhookEventData, ResendEmailAttachment); EmailProcessingResult and ExtractedReceiptDatabackend/src/_system/migrations/run-all.ts-- Registered features/email-ingestion in MIGRATION_ORDER after notificationsValidation
877f844feat: add email ingestion database schema and types (refs #154)Verdict: PASS | Next: Proceed with remaining #149 sub-issues