-- ============================================================
-- stalls_setup.sql  —  Run once in phpMyAdmin on ampsinfo DB
-- ============================================================

-- Stall bookings table (vendor-specific)
CREATE TABLE IF NOT EXISTS `vendor_stall_bookings` (
  `id`           INT AUTO_INCREMENT PRIMARY KEY,
  `vendor_id`    INT NOT NULL,
  `stall_id`     INT NOT NULL,
  `expo_id`      INT NOT NULL DEFAULT 0,
  `booking_date` DATE DEFAULT NULL,
  `status`       ENUM('pending','approved','rejected') DEFAULT 'pending',
  `booked_at`    TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY `unique_stall` (`stall_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Add missing columns to existing stalls table (safe to run even if columns exist)
ALTER TABLE stalls ADD COLUMN IF NOT EXISTS stall_size  VARCHAR(100) DEFAULT NULL;
ALTER TABLE stalls ADD COLUMN IF NOT EXISTS stall_type  VARCHAR(100) DEFAULT NULL;
ALTER TABLE stalls ADD COLUMN IF NOT EXISTS stall_name  VARCHAR(255) DEFAULT NULL;
ALTER TABLE stalls ADD COLUMN IF NOT EXISTS booking_status VARCHAR(20) DEFAULT 'available';

-- Sample stalls for testing (only inserts if stall_number doesn't already exist)
INSERT IGNORE INTO stalls (stall_name, stall_number, stall_type, stall_size, price, booking_status)
VALUES
  ('Alpha Education Corner',  'S-101', 'Books & Publications',      '10x10 ft', 5000.00,  'available'),
  ('Beta Tech Hub',           'S-102', 'Computers & IT Equipment',  '12x12 ft', 8000.00,  'available'),
  ('Gamma Stationery Zone',   'S-103', 'Stationery & Art Supplies', '8x10 ft',  3500.00,  'available'),
  ('Delta Smart Board Stall', 'S-104', 'Smart Boards & AV Equipment','15x15 ft',12000.00, 'available'),
  ('Epsilon Uniform Store',   'S-105', 'School Uniforms & Accessories','10x12 ft',6000.00, 'available');
