Sindbad~EG File Manager
-- Ministries & Groups Module Database Schema
-- Created: 2025-11-20
-- Ministry Categories Table
CREATE TABLE IF NOT EXISTS ministry_categories (
id INT AUTO_INCREMENT PRIMARY KEY,
category_name VARCHAR(100) NOT NULL UNIQUE,
category_description TEXT,
icon VARCHAR(50),
color VARCHAR(20),
display_order INT DEFAULT 0,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_active (is_active),
INDEX idx_order (display_order)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Ministries Table
CREATE TABLE IF NOT EXISTS ministries (
id INT AUTO_INCREMENT PRIMARY KEY,
ministry_name VARCHAR(255) NOT NULL,
ministry_type ENUM('ministry', 'group', 'intervention') DEFAULT 'ministry',
category_id INT,
description TEXT,
mission_statement TEXT,
area_id INT,
district_id INT,
assembly_id INT NOT NULL,
leader_member_id INT,
founding_date DATE,
meeting_schedule VARCHAR(255),
meeting_venue VARCHAR(255),
contact_person VARCHAR(100),
contact_phone VARCHAR(20),
contact_email VARCHAR(100),
total_members INT DEFAULT 0,
is_active BOOLEAN DEFAULT TRUE,
created_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (category_id) REFERENCES ministry_categories(id) ON DELETE SET NULL,
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 CASCADE,
FOREIGN KEY (leader_member_id) REFERENCES members(id) ON DELETE SET NULL,
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
INDEX idx_type (ministry_type),
INDEX idx_category (category_id),
INDEX idx_assembly (assembly_id),
INDEX idx_active (is_active),
INDEX idx_name (ministry_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Ministry Positions Table
CREATE TABLE IF NOT EXISTS ministry_positions (
id INT AUTO_INCREMENT PRIMARY KEY,
position_name VARCHAR(100) NOT NULL,
position_description TEXT,
ministry_id INT,
level INT DEFAULT 1, -- 1=leadership, 2=core, 3=general
responsibilities TEXT,
requirements TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (ministry_id) REFERENCES ministries(id) ON DELETE CASCADE,
INDEX idx_ministry (ministry_id),
INDEX idx_active (is_active),
INDEX idx_level (level)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Ministry Members Table
CREATE TABLE IF NOT EXISTS ministry_members (
id INT AUTO_INCREMENT PRIMARY KEY,
ministry_id INT NOT NULL,
member_id INT NOT NULL,
join_date DATE NOT NULL,
status ENUM('active', 'inactive', 'suspended') DEFAULT 'active',
notes TEXT,
added_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (ministry_id) REFERENCES ministries(id) ON DELETE CASCADE,
FOREIGN KEY (member_id) REFERENCES members(id) ON DELETE CASCADE,
FOREIGN KEY (added_by) REFERENCES users(id) ON DELETE SET NULL,
INDEX idx_ministry (ministry_id),
INDEX idx_member (member_id),
INDEX idx_status (status),
UNIQUE KEY unique_ministry_member (ministry_id, member_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Insert default categories (skip if already exists)
INSERT IGNORE INTO ministry_categories (category_name, category_description, icon, color, display_order) VALUES
('Worship & Music', 'Ministries related to worship, praise, and music', 'music', '#3B82F6', 1),
('Children & Youth', 'Ministries focused on children and youth development', 'users', '#10B981', 2),
('Evangelism & Missions', 'Outreach and missionary activities', 'globe', '#F97316', 3),
('Education & Training', 'Teaching and discipleship programs', 'book', '#6366F1', 4),
('Care & Support', 'Pastoral care and support groups', 'heart', '#EC4899', 5),
('Administration', 'Church administrative and operational teams', 'cog', '#8B5CF6', 6),
('Special Interest Groups', 'Fellowship and special interest groups', 'users-cog', '#14B8A6', 7);
-- Insert default ministries (skip if already exists)
INSERT IGNORE INTO ministries (ministry_name, ministry_type, category_id, description, assembly_id, meeting_schedule, is_active, created_by) VALUES
('Choir Ministry', 'ministry', 1, 'Church choir and special music ministry', 1, 'Every Sunday at 8:00 AM', TRUE, 1),
('Sunday School', 'ministry', 2, 'Children Sunday school program', 1, 'Every Sunday at 9:00 AM', TRUE, 1),
('Youth Ministry', 'ministry', 2, 'Youth fellowship and discipleship', 1, 'Saturday at 4:00 PM', TRUE, 1),
('Evangelism Team', 'ministry', 3, 'Outreach and evangelism activities', 1, 'First Saturday of month', TRUE, 1),
('Ushering Ministry', 'ministry', 6, 'Church ushering and hospitality', 1, 'Every Sunday', TRUE, 1),
('Women Fellowship', 'group', 5, 'Women ministry and fellowship', 1, 'Last Saturday of month', TRUE, 1),
('Men Fellowship', 'group', 5, 'Men ministry and fellowship', 1, 'Second Saturday of month', TRUE, 1);
-- Insert default positions (skip if already exists)
INSERT IGNORE INTO ministry_positions (position_name, position_description, ministry_id, level, is_active) VALUES
('Ministry Leader', 'Overall leader of the ministry', NULL, 1, TRUE),
('Assistant Leader', 'Deputy leader supporting the main leader', NULL, 1, TRUE),
('Secretary', 'Handles ministry documentation and communication', NULL, 2, TRUE),
('Treasurer', 'Manages ministry finances', NULL, 2, TRUE),
('Coordinator', 'Coordinates ministry activities', NULL, 2, TRUE),
('Member', 'General ministry member', NULL, 3, TRUE);
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists