Jobs Table Schema
The jobs table (wp_smi_jobs) provides comprehensive tracking of the complete image processing workflow.
Table Structure
Core Identification
id– Auto-increment primary keyjob_id– UUID unique identifier for external referencespost_id– WordPress post where image appearsattachment_id– WordPress media library reference
Image Information
image_url– Original image URL for processingimage_width– Original image width in pixelsimage_height– Original image height in pixelsresolution– Target upscaling factor (‘4x’, ‘8x’)
Processing Status
status– Job processing stateawaiting_payment– Stripe checkout createdpending– Payment received, ready for processingprocessing– Upsampler API processing imagecompleted– Ready for downloadfailed– Processing error occurredabandoned– Payment not completed
Financial Tracking
Payment Integration
stripe_payment_intent_id– Stripe payment referencestripe_checkout_session_id– Stripe session trackingpayment_status– Payment state (‘pending’, ‘paid’, ‘failed’)paid_at– Payment completion timestamp
Cost Analysis
amount_charged– Customer payment amountamount_cost– Processing cost calculationcredits_used– Upsampler credits consumedrefunded_at– Refund processing timestamprefund_amount– Refund amount issuedrefund_reason– Reason for refund
Processing Workflow
External Service Integration
upsampler_job_id– External processing referenceupscaled_url– Temporary processed image URLupscaled_file_path– Local storage path
Download Management
download_token– Secure 64-character access tokendownload_expires_at– Token expiration timestampemail_sent– Notification delivery confirmation
Timestamp Tracking
Lifecycle Timestamps
created_at– Job creation (auto-generated)updated_at– Last modification (auto-updated)processing_started_at– Upscaling initiationcompleted_at– Processing completionfailed_at– Error occurrence
Customer Communication
email– Customer email for notifications (NOT NULL)email_sent– Boolean delivery confirmation
Database Indexes
Performance Optimization
UNIQUE KEY job_id (job_id) -- UUID lookups
KEY post_id (post_id) -- Post-based queries
KEY attachment_id (attachment_id) -- Attachment queries
KEY post_attachment (post_id, attachment_id) -- Analytics composite
KEY status (status) -- Status filtering
KEY payment_status (payment_status) -- Financial queries
KEY download_token (download_token) -- Secure downloads
KEY created_at (created_at) -- Time-based queries
Data Types and Constraints
Field Specifications
job_id– VARCHAR(255) NOT NULL UNIQUEemail– VARCHAR(255) NOT NULLamount_*– DECIMAL(10,2) for financial precision*_at– DATETIME for timestamp storagedownload_token– VARCHAR(64) for secure access
Data Validation
- Job ID uniqueness enforced at database level
- Foreign key relationships with WordPress tables
- Status values validated against constants
- Financial amounts stored with currency precision
Query Patterns
Common Queries
-- Active jobs requiring processing
SELECT * FROM wp_smi_jobs
WHERE status = 'pending'
ORDER BY created_at ASC;
-- Jobs ready for cleanup
SELECT * FROM wp_smi_jobs
WHERE download_expires_at < NOW()
AND upscaled_file_path IS NOT NULL;
-- Revenue analysis
SELECT SUM(amount_charged) as revenue,
COUNT(*) as completed_jobs
FROM wp_smi_jobs
WHERE status = 'completed'
AND created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY);
Maintenance Operations
Cleanup Procedures
- Expired download file removal
- Old job record archival
- Failed job cleanup
- Temporary file management
Data Retention
- Configurable retention periods
- Automatic cleanup schedules
- Manual purge capabilities
- Export before deletion