-- ============================================================================
-- Gallery Table & Logo Settings - Database Updates
-- ============================================================================
-- Run this SQL on your database (advaysin_gmind) to add the gallery table
-- and new settings for site_logo and affiliation_logo.
-- ============================================================================

-- Gallery Table (if not already created by you)
CREATE TABLE IF NOT EXISTS `gallery` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL COMMENT 'Image title',
    `category` VARCHAR(100) DEFAULT NULL COMMENT 'Category e.g. Events, Campus, Classroom',
    `description` TEXT DEFAULT NULL COMMENT 'Brief description',
    `image` VARCHAR(500) NOT NULL COMMENT 'Path to gallery image',
    `sort_order` INT NOT NULL DEFAULT 0 COMMENT 'Display order (lower = first)',
    `active` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '1=visible, 0=hidden',
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    INDEX `idx_gallery_category` (`category`),
    INDEX `idx_gallery_active_sort` (`active`, `sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Photo gallery items';

-- Add site_logo setting (for dynamic logo in header)
INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES ('site_logo', 'uploads/logo.png')
ON DUPLICATE KEY UPDATE `setting_value` = `setting_value`;

-- Add affiliation_logo setting (for affiliation page logo)
INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES ('affiliation_logo', '')
ON DUPLICATE KEY UPDATE `setting_value` = `setting_value`;

-- Add missing settings used by HomeController and views
INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES ('stat_placement_rate', '85')
ON DUPLICATE KEY UPDATE `setting_value` = `setting_value`;

INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES ('contact_phone', '9305640290')
ON DUPLICATE KEY UPDATE `setting_value` = `setting_value`;

INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES ('contact_email', 'info@gmind.in')
ON DUPLICATE KEY UPDATE `setting_value` = `setting_value`;

INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES ('address', '123 Education Street, New Delhi, India')
ON DUPLICATE KEY UPDATE `setting_value` = `setting_value`;

-- ============================================================================
-- End of Updates
-- ============================================================================
