ferrero-opentext/Python-Version/migrations/add_dam_asset_id_to_derivatives.sql
DJP c901a79e24 Fix A2→A3 email template and database logging issues
Email Template Fix:
- Fixed subject line syntax error in a2_to_a3_batch_complete template
- Removed Jinja2 control flow ({% if %}) from subject line
- Changed to simple expression-only format
- Fixes 'Failed to send email' error

Database Logging Fix:
- Updated get_master_asset() to return database primary key 'id'
- Updated store_derivative_asset() to actually store master_asset_id and dam_asset_id
- Updated a2_to_a3_upload_polling.py to pass master_asset['id'] instead of None
- Added migration script to add dam_asset_id column to derivative_assets table
- Fixes issue where derivatives weren't being linked to masters in database
- Enables proper lookups and tracking of uploaded derivatives

Impact:
- Email notifications will now send successfully
- Derivatives will be properly logged and linked to master assets
- Other tools can now find uploaded derivatives in database
2025-12-22 10:12:36 -05:00

14 lines
495 B
SQL

-- Migration: Add dam_asset_id column to derivative_assets table
-- Date: 2025-12-22
-- Purpose: Store DAM asset ID for uploaded derivatives to enable proper tracking and lookups
-- Add dam_asset_id column if it doesn't exist
ALTER TABLE derivative_assets
ADD COLUMN IF NOT EXISTS dam_asset_id VARCHAR(255);
-- Add index for faster lookups by DAM asset ID
CREATE INDEX IF NOT EXISTS idx_derivative_assets_dam_id
ON derivative_assets(dam_asset_id);
-- Verify the change
\d derivative_assets