- Add album content field for rich text/structured content - Add geolocation support for albums with position and zoom level - Remove direct photo-album relationship in favor of MediaAlbum join table - Support many-to-many relationships between media and albums - Add Album relation to Universe model for better organization This enables albums to have rich content beyond just photos and supports geographic data for location-based albums. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
24 lines
No EOL
745 B
SQL
24 lines
No EOL
745 B
SQL
-- Step 1: Migrate any remaining direct photo-album relationships to AlbumMedia
|
|
INSERT INTO "AlbumMedia" ("albumId", "mediaId", "displayOrder", "createdAt")
|
|
SELECT DISTINCT
|
|
p."albumId",
|
|
p."mediaId",
|
|
p."displayOrder",
|
|
p."createdAt"
|
|
FROM "Photo" p
|
|
WHERE p."albumId" IS NOT NULL
|
|
AND p."mediaId" IS NOT NULL
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM "AlbumMedia" am
|
|
WHERE am."albumId" = p."albumId"
|
|
AND am."mediaId" = p."mediaId"
|
|
);
|
|
|
|
-- Step 2: Drop the foreign key constraint
|
|
ALTER TABLE "Photo" DROP CONSTRAINT IF EXISTS "Photo_albumId_fkey";
|
|
|
|
-- Step 3: Drop the albumId column from Photo table
|
|
ALTER TABLE "Photo" DROP COLUMN IF EXISTS "albumId";
|
|
|
|
-- Step 4: Drop the index on albumId
|
|
DROP INDEX IF EXISTS "Photo_albumId_idx"; |