seedproject-web/api/db/migrations/010_create_cja_media.sql
Carlos Arias dc69d1fd0d Phase 2: media upload pipeline
- cja_media table; POST /api/media/upload (admin-gated, multipart).
- Images optimised with GD (downscale to 1600px, re-encode; WebP for
  transparency, JPG for photos). Video via ffmpeg (scale, compress, drop audio).
- Stored in app/public/media/ (source tree) so uploads survive rebuilds and are
  copied into public/ on build.
- requireAdmin() moved to PublicController base (fixes a static/non-static
  clash with AdminAuth). Type detection uses getimagesize (fileinfo ext absent).

Note: php-fpm must be in the caweb group to write app/public/media (restart
after adding www to caweb).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DoFYZY9gkGPNDqZ7NuEa9a
2026-07-23 22:45:45 +00:00

21 lines
1 KiB
SQL

-- Media library for the admin console.
--
-- Every uploaded image/video, optimised and stored under app/public/media/
-- (source tree, so it survives rebuilds and is copied into public/ on build).
-- Rows let the admin browse and reuse uploads rather than re-uploading.
CREATE TABLE IF NOT EXISTS `cja_media` (
`media_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`kind` enum('image','video') NOT NULL DEFAULT 'image',
`url` varchar(255) NOT NULL, -- e.g. /media/ginny-goldman-a1b2.jpg
`filename` varchar(255) NOT NULL,
`mime` varchar(80) NOT NULL DEFAULT '',
`width` int(10) unsigned DEFAULT NULL,
`height` int(10) unsigned DEFAULT NULL,
`bytes` int(10) unsigned DEFAULT NULL,
`alt` varchar(255) NOT NULL DEFAULT '',
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`media_id`),
UNIQUE KEY `uq_cja_media_url` (`url`),
KEY `idx_cja_media_feed` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;