-- Create renewals table
CREATE TABLE IF NOT EXISTS `renewals` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `member_id` INT(11) NOT NULL,
    `amount` DECIMAL(10,2) NOT NULL,
    `payment_method` VARCHAR(50) DEFAULT 'online',
    `transaction_id` VARCHAR(255) DEFAULT NULL,
    `renewal_date` DATE NOT NULL,
    `expiry_date` DATE NOT NULL,
    `status` ENUM('pending', 'completed', 'failed') DEFAULT 'completed',
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_member_id` (`member_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Create events table
CREATE TABLE IF NOT EXISTS `events` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `description` TEXT,
    `event_date` DATE NOT NULL,
    `event_time` TIME DEFAULT NULL,
    `venue` VARCHAR(255) DEFAULT NULL,
    `address` TEXT,
    `max_attendees` INT(11) DEFAULT NULL,
    `current_attendees` INT(11) DEFAULT 0,
    `banner_image` VARCHAR(255) DEFAULT NULL,
    `status` ENUM('upcoming', 'ongoing', 'completed', 'cancelled') DEFAULT 'upcoming',
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Create event_registrations table
CREATE TABLE IF NOT EXISTS `event_registrations` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `event_id` INT(11) NOT NULL,
    `member_id` INT(11) NOT NULL,
    `registration_date` DATETIME DEFAULT CURRENT_TIMESTAMP,
    `status` ENUM('confirmed', 'cancelled') DEFAULT 'confirmed',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;