Database Changes:
- ALTER TABLE master_assets ADD COLUMN full_metadata JSONB
- Stores COMPLETE DAM asset metadata (no 5,000 char truncation)
- PostgreSQL JSONB type for efficient storage and querying
DatabaseClient Changes:
- Added full_metadata to INSERT and ON CONFLICT UPDATE
- Store complete json_encode($assetData) in full_metadata column
- Simplified description to just Box info (no metadata)
- Log metadata size when storing
- NO TRUNCATION - preserves all fields
Workflow Changes (workflow_v3.php):
- load_master_metadata: Read from full_metadata JSONB column
- upload_from_box: Read from full_metadata JSONB column
- Both endpoints now get COMPLETE master metadata
- Added logging for metadata size verification
Impact:
BEFORE: Only 5,000 chars stored (truncated)
AFTER: Full metadata stored (10,000+ chars, all fields preserved)
Next Step:
Re-download master assets to populate full_metadata for existing records.
New downloads will automatically use the new column.
🤖 Generated with Claude Code
DatabaseClient now exposes the PDO connection via getConnection().
This allows the upload_from_box AJAX endpoint to query the database.
🤖 Generated with Claude Code
Will show:
- What value structure is found
- Which path is used (domain vs regular)
- Why fields return NULL
This will reveal the actual value structure for SUB BRAND, MAIN LANGUAGES, etc.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Removed:
- CAMPAIGN_BRAND lookup (doesn't exist in assets)
- CAMPAIGN_MARKET lookup (doesn't exist in assets)
Improved:
- SUB BRAND extraction
- MAIN LANGUAGES tabular field handling
- MKTG.ASSET TYPE extraction
These fields actually exist in the asset metadata.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixed metadata extraction to use fields that exist in assets:
- SUB BRAND → brand_name, brand_code
- MAIN LANGUAGES → language_code
- MKTG.ASSET TYPE → asset_type
- master_content_info → width_px, height_px
Campaign-level fields (CAMPAIGN_BRAND, CAMPAIGN_MARKET) don't exist
on individual assets - they're on the campaign folder.
Using asset-level fields that are actually present.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Log every metadata field encountered to see:
- Which fields are in the metadata
- Why CAMPAIGN_BRAND and CAMPAIGN_MARKET aren't being found
- Structure of metadata categories
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Debug what's being passed:
- AssetData keys available
- Upload folder ID value
- Master assets count and structure
- Asset metadata keys per file
This will show exactly what data is available for extraction.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Logging to troubleshoot why fields aren't being populated:
- Log extracted metadata values
- Log upload folder ID
- Log width/height extraction
- Check asset_content_info structure variations
Will show in logs what's being extracted vs what's NULL.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
DatabaseClient now extracts and stores:
- brand_code, brand_name (from FERRERO.FIELD.CAMPAIGN_BRAND)
- country_code (from FERRERO.FIELD.CAMPAIGN_MARKET)
- language_code (to be extracted from filename or metadata)
- asset_type (from metadata fields)
- width_px, height_px (from asset_content_info.master_content)
- file_size_bytes (from asset data)
- mime_type (from asset data)
- upload_directory (Final Assets folder ID passed from workflow)
Handles both domain values and regular values.
Populates all available database columns from DAM metadata.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Database:
- Store full DAM metadata JSON in description field (5KB limit)
- Includes Box links and upload folder ID
- Full asset metadata preserved
Box Metadata Template Testing:
- Simplified to send just test string first
- Log endpoint and values being sent
- Try 5 field name variations
- Will identify correct field name from logs
Next test will show which field name works for Box template.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Database now stores:
- upload_directory = Final Assets folder ID from DAM
- This is the target folder for A2→A3 uploads
- Can be retrieved later when uploading processed files back to DAM
Column exists in DB, now being populated correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Workflow Enhancement:
- When getting Master Assets, also find Final Assets folder
- Store Final Assets folder ID in session for later upload use
- Pass upload folder ID to database storage
Database Storage:
- Store upload folder ID in description field
- Ready for dedicated upload_directory column when added to DB schema
UI Update:
- Success message shows Final Assets folder was located
This ensures we have the upload target folder ID when needed for A2→A3 workflow.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Box Metadata Template:
- Fixed template key: 'ferrerodammetadata' (lowercase)
- Fixed field name: 'DAM-Metadata' (exact from template)
- Should now properly attach metadata to Box files
Database Fix:
- Removed non-existent columns: box_file_id, box_url, dam_metadata_json
- Using only existing columns from master_assets table
- Storing Box URL in description field as workaround
- Will add proper columns in DB migration later
Next: Box metadata template should work, DB inserts should succeed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Database Integration:
- IDGenerator now connects to PostgreSQL (localhost:5433)
- Generates tracking IDs with uniqueness check against master_assets table
- Fallback to random if database unavailable
- Direct PDO connection to ferrero_tracking database
DatabaseClient:
- Stores master assets in PostgreSQL
- Records: tracking_id, opentext_id, Box links, full metadata JSON
- Updates on conflict (upsert pattern)
- Stores box_file_id and box_url for reference
Box Metadata Enhancement:
- Uses Box metadata template API (enterprise/ferreroDAMMetadata)
- Stores full DAM metadata JSON in 'Ferrero-DAM-Metadata' field
- Fallback to file description if template not configured
- Handles template conflicts (updates existing)
Box Upload Results Now Show:
- Unique tracking ID (from database)
- Box file links (clickable)
- Database storage status
- ID source (database_direct, random, etc.)
Complete workflow: DAM → Download → Generate ID → Upload to Box → Store in DB
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>