ferrero-naming-tool/database/seed.sql
DJP 7233a49252 Add v2 with PostgreSQL tracking ID system for asset lifecycle management
Implements complete tracking ID system for linking derivative assets to master files with automatic metadata inheritance.

Major features:
- v2 web interface (public-v2/) with tracking ID support
- PostgreSQL database (Docker) for master asset metadata storage
- 6-character alphanumeric tracking IDs with collision-free generation
- OpenText DAM integration with metadata import script
- Upload simulator showing filename transformations (strips job number and tracking ID)
- Visual transformation flow display
- Complete asset lifecycle event logging with triggers
- Database schema with optimized indexes and views
- Helper scripts for database management (db-start.sh, db-stop.sh)

Technical implementation:
- PostgreSQL 15 in Docker on port 5433 (md5 auth for MAMP compatibility)
- PHP PDO with singleton database class
- Automatic event logging via PostgreSQL triggers
- JSON storage for naming convention data (shared with v1)
- Case-sensitive tracking ID input fields

Both v1 (simple) and v2 (tracking) versions coexist for different workflows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 12:24:35 -04:00

204 lines
4 KiB
SQL

-- Seed data for testing and demonstration
-- Insert example tracking ID into log
INSERT INTO tracking_id_log (tracking_id, assigned_to_asset, assigned_at)
VALUES ('a7K9mP', TRUE, CURRENT_TIMESTAMP);
-- Insert example master asset
INSERT INTO master_assets (
tracking_id,
opentext_id,
original_filename,
file_extension,
brand_code,
brand_name,
country_code,
country_name,
language_code,
language_name,
subject_title,
asset_type,
asset_type_name,
duration_seconds,
aspect_ratio,
file_size_bytes,
mime_type,
width_px,
height_px,
tags,
categories,
description,
status,
ingested_by
) VALUES (
'a7K9mP',
'OT_12345',
'06_RAFFAELLO_MAESTRO_SD',
'.mp4',
'RAF',
'RAFFAELLO',
'GL',
'Global',
'en',
'English',
'MAESTRO SD',
'OLV',
'On Line Video',
30,
'16x9',
52428800, -- 50MB
'video/mp4',
1920,
1080,
ARRAY['master', 'video', 'campaign'],
ARRAY['raffaello', 'maestro'],
'Master asset for Raffaello Maestro campaign',
'active',
'system'
);
-- Generate a few more example tracking IDs for demonstration
INSERT INTO tracking_id_log (tracking_id, assigned_to_asset)
VALUES
('b3Xk2N', FALSE),
('c9Qm4P', FALSE),
('d5Wp7R', FALSE),
('e1Zn8T', FALSE);
-- Insert additional example master assets
INSERT INTO master_assets (
tracking_id,
opentext_id,
original_filename,
file_extension,
brand_code,
brand_name,
country_code,
country_name,
language_code,
language_name,
subject_title,
asset_type,
asset_type_name,
duration_seconds,
aspect_ratio,
tags,
description,
status,
ingested_by
) VALUES
(
'b3Xk2N',
'OT_12346',
'07_NUTELLA_BREAKFAST_HD',
'.mp4',
'NUT',
'NUTELLA',
'IT',
'Italy',
'it',
'Italian',
'BREAKFAST HD',
'TVC',
'TV Commercial',
15,
'16x9',
ARRAY['master', 'video', 'breakfast'],
'Nutella breakfast campaign master',
'active',
'system'
),
(
'c9Qm4P',
'OT_12347',
'08_KINDER_BUENO_XMAS',
'.mp4',
'BUE',
'KINDER BUENO',
'DE',
'Germany',
'de',
'German',
'XMAS CAMPAIGN',
'OLV',
'On Line Video',
20,
'1x1',
ARRAY['master', 'video', 'christmas'],
'Kinder Bueno Christmas campaign',
'active',
'system'
);
-- Insert example derivative assets
INSERT INTO derivative_assets (
tracking_id,
derivative_filename,
file_extension,
master_asset_id,
language_code,
language_name,
asset_type,
asset_type_name,
duration_seconds,
aspect_ratio,
omg_job_number,
spot_version,
has_master_flag,
status,
created_by
) VALUES
(
'a7K9mP',
'RAF_CH_de_TEST_FILE_OLV_001_15S_16x9',
'.mp4',
(SELECT id FROM master_assets WHERE tracking_id = 'a7K9mP'),
'de',
'German',
'OLV',
'On Line Video',
15,
'16x9',
'1234567',
'001',
FALSE,
'active',
'user@ferrero.com'
),
(
'a7K9mP',
'RAF_IT_it_ME_MOMENT_OLV_6S_1x1',
'.mp4',
(SELECT id FROM master_assets WHERE tracking_id = 'a7K9mP'),
'it',
'Italian',
'OLV',
'On Line Video',
6,
'1x1',
'1234568',
NULL,
FALSE,
'active',
'user@ferrero.com'
);
-- Add some lifecycle events manually (in addition to those auto-created by triggers)
INSERT INTO asset_lifecycle_events (tracking_id, event_type, event_data, user_id)
VALUES
(
'a7K9mP',
'metadata_updated',
'{"field": "description", "old_value": "", "new_value": "Master asset for Raffaello Maestro campaign"}'::jsonb,
'admin@ferrero.com'
),
(
'b3Xk2N',
'quality_check_completed',
'{"status": "approved", "reviewer": "quality_team", "notes": "HD quality verified"}'::jsonb,
'qa@ferrero.com'
);
-- Grant permissions (adjust as needed for your security requirements)
-- GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly_user;
-- GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO readwrite_user;