Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/sql/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/sql/create_events_table_simple.sql

-- Create events table if it doesn't exist and add sample data

-- Create basic events table
CREATE TABLE IF NOT EXISTS events (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    description TEXT,
    start_date DATETIME,
    end_date DATETIME,
    location_id INT,
    location_type ENUM('area', 'district', 'assembly') DEFAULT 'assembly',
    is_active BOOLEAN DEFAULT TRUE,
    registration_status ENUM('open', 'closed', 'pending') DEFAULT 'open',
    registration_open_date DATETIME,
    registration_close_date DATETIME,
    registration_message TEXT,
    created_by INT DEFAULT 1,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    
    -- Additional columns for conference page
    featured BOOLEAN DEFAULT FALSE,
    image_url VARCHAR(500) NULL,
    max_attendees INT NULL,
    registration_fee DECIMAL(10,2) DEFAULT 0.00,
    event_type ENUM('conference', 'workshop', 'rally', 'service', 'program', 'fellowship', 'other') DEFAULT 'other',
    public_registration BOOLEAN DEFAULT TRUE,
    require_approval BOOLEAN DEFAULT FALSE,
    
    INDEX idx_location_id (location_id),
    INDEX idx_location_type (location_type),
    INDEX idx_start_date (start_date),
    INDEX idx_is_active (is_active),
    INDEX idx_featured (featured),
    INDEX idx_public_registration (public_registration)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Clear any existing sample events
DELETE FROM events WHERE name LIKE '%Sample%' OR name LIKE '%Test%' OR created_by = 1;

-- Add sample events with future dates
INSERT INTO events (
    name, description, start_date, end_date, location_type, is_active, 
    registration_status, featured, event_type, public_registration, 
    registration_fee, max_attendees, created_by
) VALUES 
-- Featured Event (next week)
(
    'Annual Church Conference 2025', 
    'Join us for our biggest event of the year featuring inspiring speakers, worship sessions, and fellowship opportunities. This conference will transform your spiritual journey.',
    DATE_ADD(NOW(), INTERVAL 7 DAY),
    DATE_ADD(NOW(), INTERVAL 9 DAY),
    'area',
    1,
    'open',
    1,
    'conference',
    1,
    0.00,
    500,
    1
),

-- Other upcoming events
(
    'Youth Leadership Workshop', 
    'Empowering the next generation of church leaders through interactive workshops and mentorship sessions.',
    DATE_ADD(NOW(), INTERVAL 14 DAY),
    DATE_ADD(NOW(), INTERVAL 14 DAY),
    'district',
    1,
    'open',
    0,
    'workshop',
    1,
    25.00,
    100,
    1
),

(
    'Community Outreach Rally', 
    'Come together to serve our community and make a positive impact in our neighborhood.',
    DATE_ADD(NOW(), INTERVAL 21 DAY),
    DATE_ADD(NOW(), INTERVAL 21 DAY),
    'assembly',
    1,
    'open',
    0,
    'rally',
    1,
    0.00,
    200,
    1
),

(
    'Marriage Enrichment Seminar', 
    'Strengthen your marriage with biblical principles and practical tools for lasting relationships.',
    DATE_ADD(NOW(), INTERVAL 28 DAY),
    DATE_ADD(NOW(), INTERVAL 28 DAY),
    'area',
    1,
    'open',
    0,
    'workshop',
    1,
    15.00,
    80,
    1
),

(
    'Sunday Service Special', 
    'Special guest speaker and worship experience celebrating our church anniversary.',
    DATE_ADD(NOW(), INTERVAL 3 DAY),
    DATE_ADD(NOW(), INTERVAL 3 DAY),
    'assembly',
    1,
    'open',
    0,
    'service',
    1,
    0.00,
    300,
    1
);

-- Verify the events were created
SELECT 
    id,
    name, 
    start_date, 
    event_type, 
    featured, 
    public_registration,
    registration_fee,
    is_active
FROM events 
WHERE is_active = 1 
ORDER BY featured DESC, start_date ASC;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists