18 lines
719 B
SQL
18 lines
719 B
SQL
-- Migration: Create drop_images table for multiple images per drop
|
|
-- This allows up to 4 images per drop
|
|
|
|
CREATE TABLE IF NOT EXISTS `drop_images` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`drop_id` int(11) NOT NULL,
|
|
`image_url` varchar(255) NOT NULL,
|
|
`display_order` int(11) NOT NULL DEFAULT 0,
|
|
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
|
PRIMARY KEY (`id`),
|
|
KEY `drop_id` (`drop_id`),
|
|
CONSTRAINT `drop_images_ibfk_1` FOREIGN KEY (`drop_id`) REFERENCES `drops` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
-- Add index for faster queries
|
|
CREATE INDEX idx_drop_images_drop_order ON drop_images(drop_id, display_order);
|
|
|