Sindbad~EG File Manager
-- Members table for church membership management
CREATE TABLE IF NOT EXISTS members (
id INT AUTO_INCREMENT PRIMARY KEY,
member_id VARCHAR(20) UNIQUE NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
phone VARCHAR(20),
date_of_birth DATE,
gender ENUM('male', 'female') NOT NULL,
marital_status ENUM('single', 'married', 'divorced', 'widowed'),
occupation VARCHAR(100),
address TEXT,
city VARCHAR(100),
state VARCHAR(100),
country VARCHAR(100) DEFAULT 'Ghana',
postal_code VARCHAR(20),
-- Church organizational structure
area_id INT,
district_id INT,
assembly_id INT,
-- Membership details
membership_type ENUM('full_member', 'associate_member', 'visitor') DEFAULT 'associate_member',
baptism_date DATE,
confirmation_date DATE,
join_date DATE NOT NULL,
membership_status ENUM('active', 'inactive', 'suspended', 'transferred') DEFAULT 'active',
-- Emergency contact
emergency_contact_name VARCHAR(200),
emergency_contact_phone VARCHAR(20),
emergency_contact_relationship VARCHAR(50),
-- Additional information
skills_talents TEXT,
ministry_interests TEXT,
notes TEXT,
-- System fields
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
created_by INT,
FOREIGN KEY (area_id) REFERENCES areas(id) ON DELETE SET NULL,
FOREIGN KEY (district_id) REFERENCES districts(id) ON DELETE SET NULL,
FOREIGN KEY (assembly_id) REFERENCES assemblies(id) ON DELETE SET NULL,
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
INDEX idx_member_id (member_id),
INDEX idx_email (email),
INDEX idx_area (area_id),
INDEX idx_district (district_id),
INDEX idx_assembly (assembly_id),
INDEX idx_status (membership_status),
INDEX idx_join_date (join_date)
);
-- Email management settings table
CREATE TABLE IF NOT EXISTS email_settings (
id INT AUTO_INCREMENT PRIMARY KEY,
smtp_host VARCHAR(255) NOT NULL,
smtp_port INT NOT NULL DEFAULT 587,
smtp_username VARCHAR(255) NOT NULL,
smtp_password VARCHAR(255) NOT NULL,
smtp_encryption ENUM('tls', 'ssl', 'none') DEFAULT 'tls',
from_email VARCHAR(255) NOT NULL,
from_name VARCHAR(255) NOT NULL,
reply_to_email VARCHAR(255),
-- Email templates
welcome_email_subject VARCHAR(255) DEFAULT 'Welcome to COP Madina!',
welcome_email_template TEXT,
-- Settings
is_active BOOLEAN DEFAULT TRUE,
daily_limit INT DEFAULT 100,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
-- Email logs table
CREATE TABLE IF NOT EXISTS email_logs (
id INT AUTO_INCREMENT PRIMARY KEY,
recipient_email VARCHAR(255) NOT NULL,
recipient_name VARCHAR(255),
recipient_type ENUM('member', 'user', 'external') NOT NULL,
recipient_id INT,
subject VARCHAR(500) NOT NULL,
body TEXT NOT NULL,
email_type ENUM('welcome', 'notification', 'reminder', 'announcement', 'custom') NOT NULL,
status ENUM('pending', 'sent', 'failed', 'bounced') DEFAULT 'pending',
sent_at TIMESTAMP NULL,
error_message TEXT,
-- Tracking
opened_at TIMESTAMP NULL,
clicked_at TIMESTAMP NULL,
-- System fields
sent_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (sent_by) REFERENCES users(id) ON DELETE SET NULL,
INDEX idx_recipient_email (recipient_email),
INDEX idx_recipient_type (recipient_type, recipient_id),
INDEX idx_status (status),
INDEX idx_email_type (email_type),
INDEX idx_sent_at (sent_at),
INDEX idx_created_at (created_at)
);
-- Insert default email settings
INSERT INTO email_settings (
smtp_host, smtp_port, smtp_username, smtp_password, from_email, from_name,
welcome_email_subject, welcome_email_template
) VALUES (
'smtp.gmail.com', 587, 'your-email@gmail.com', 'your-app-password',
'noreply@copmadinaconf.org', 'COP Madina Conference',
'Welcome to COP Madina Church!',
'<h2>Welcome to COP Madina!</h2>
<p>Dear {member_name},</p>
<p>We are delighted to welcome you to the Church of Pentecost - Madina Area family!</p>
<p><strong>Your Membership Details:</strong></p>
<ul>
<li>Member ID: {member_id}</li>
<li>Area: {area_name}</li>
<li>District: {district_name}</li>
<li>Assembly: {assembly_name}</li>
<li>Join Date: {join_date}</li>
</ul>
<p>We look forward to your active participation in our church activities and spiritual growth.</p>
<p>God bless you!</p>
<p><strong>COP Madina Leadership Team</strong></p>'
) ON DUPLICATE KEY UPDATE id=id;
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists