-- Migration: Ajouter la table pack_avatars (liaison packs -> avatars)
-- Utilisée par le webhook Stripe (packs avatars)
-- Date: 2026-02-09

CREATE TABLE IF NOT EXISTS `pack_avatars` (
  `pack_id` varchar(50) NOT NULL,
  `avatar_id` int NOT NULL,
  `display_order` int DEFAULT '0',
  PRIMARY KEY (`pack_id`,`avatar_id`),
  KEY `idx_pack_avatars_pack` (`pack_id`),
  KEY `idx_pack_avatars_avatar` (`avatar_id`),
  CONSTRAINT `pack_avatars_ibfk_1` FOREIGN KEY (`pack_id`) REFERENCES `avatar_packs` (`pack_id`) ON DELETE CASCADE,
  CONSTRAINT `pack_avatars_ibfk_2` FOREIGN KEY (`avatar_id`) REFERENCES `avatars` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

