| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/project-slim/database/ |
Upload File : |
-- Project Slim Database Schema
-- MAMP MySQL Database Setup
-- Create database
CREATE DATABASE IF NOT EXISTS project_slim CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE project_slim;
-- Companies table
CREATE TABLE companies (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
phone VARCHAR(20),
website VARCHAR(255),
address TEXT NOT NULL,
city VARCHAR(100) NOT NULL,
state VARCHAR(100),
country VARCHAR(100) NOT NULL,
postal_code VARCHAR(20),
industry ENUM('technology', 'healthcare', 'finance', 'education', 'retail', 'manufacturing', 'construction', 'transportation', 'energy', 'entertainment', 'consulting', 'real_estate', 'agriculture', 'other'),
company_size ENUM('1-10', '11-50', '51-200', '201-500', '501-1000', '1000+'),
tax_id VARCHAR(50),
status ENUM('active', 'inactive', 'suspended') DEFAULT 'active',
logo VARCHAR(255),
founded_year YEAR,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_status (status),
INDEX idx_industry (industry),
INDEX idx_created_at (created_at)
) ENGINE=InnoDB;
-- Users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
phone VARCHAR(20),
role ENUM('admin', 'manager', 'employee', 'viewer') DEFAULT 'employee',
status ENUM('active', 'inactive') DEFAULT 'active',
avatar VARCHAR(255),
timezone VARCHAR(50) DEFAULT 'UTC',
company_id INT,
email_verified BOOLEAN DEFAULT FALSE,
email_verified_at TIMESTAMP NULL,
two_factor_enabled BOOLEAN DEFAULT FALSE,
two_factor_secret VARCHAR(32),
remember_token VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE SET NULL,
INDEX idx_email (email),
INDEX idx_status (status),
INDEX idx_role (role),
INDEX idx_company_id (company_id),
INDEX idx_created_at (created_at)
) ENGINE=InnoDB;
-- Reports table
CREATE TABLE reports (
id INT AUTO_INCREMENT PRIMARY KEY,
type ENUM('financial_summary', 'sales_report', 'user_activity', 'performance_metrics', 'compliance_report', 'audit_log', 'custom_report', 'monthly_summary', 'quarterly_review', 'annual_report') NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
company_id INT NOT NULL,
user_id INT NOT NULL,
status ENUM('draft', 'processing', 'completed', 'failed', 'cancelled', 'archived') DEFAULT 'draft',
priority ENUM('low', 'medium', 'high', 'urgent') DEFAULT 'medium',
format ENUM('pdf', 'excel', 'csv', 'json') DEFAULT 'pdf',
file_path VARCHAR(500),
file_size BIGINT,
date_from DATE,
date_to DATE,
filters JSON,
metadata JSON,
generated_at TIMESTAMP NULL,
expires_at TIMESTAMP NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_type (type),
INDEX idx_status (status),
INDEX idx_company_id (company_id),
INDEX idx_user_id (user_id),
INDEX idx_created_at (created_at),
INDEX idx_date_range (date_from, date_to)
) ENGINE=InnoDB;
-- User sessions table (for tracking active sessions)
CREATE TABLE user_sessions (
id VARCHAR(255) PRIMARY KEY,
user_id INT NOT NULL,
ip_address VARCHAR(45),
user_agent TEXT,
device_name VARCHAR(255),
location VARCHAR(255),
last_activity TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_user_id (user_id),
INDEX idx_last_activity (last_activity)
) ENGINE=InnoDB;
-- Password reset tokens table
CREATE TABLE password_reset_tokens (
email VARCHAR(255) PRIMARY KEY,
token VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_token (token),
INDEX idx_created_at (created_at)
) ENGINE=InnoDB;
-- Email verification tokens table
CREATE TABLE email_verification_tokens (
user_id INT PRIMARY KEY,
token VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_token (token),
INDEX idx_created_at (created_at)
) ENGINE=InnoDB;
-- Report schedules table
CREATE TABLE report_schedules (
id INT AUTO_INCREMENT PRIMARY KEY,
type ENUM('financial_summary', 'sales_report', 'user_activity', 'performance_metrics', 'compliance_report', 'audit_log', 'custom_report', 'monthly_summary', 'quarterly_review', 'annual_report') NOT NULL,
title VARCHAR(255) NOT NULL,
company_id INT NOT NULL,
user_id INT NOT NULL,
frequency ENUM('daily', 'weekly', 'monthly', 'quarterly', 'yearly') NOT NULL,
format ENUM('pdf', 'excel', 'csv', 'json') DEFAULT 'pdf',
recipients JSON,
filters JSON,
start_date DATE NOT NULL,
end_date DATE,
last_run TIMESTAMP NULL,
next_run TIMESTAMP NOT NULL,
status ENUM('active', 'paused', 'cancelled') DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_next_run (next_run),
INDEX idx_status (status),
INDEX idx_company_id (company_id)
) ENGINE=InnoDB;
-- Report shares table
CREATE TABLE report_shares (
id INT AUTO_INCREMENT PRIMARY KEY,
report_id INT NOT NULL,
shared_by INT NOT NULL,
recipient_email VARCHAR(255) NOT NULL,
permissions JSON,
message TEXT,
expires_at TIMESTAMP NULL,
accessed_at TIMESTAMP NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (report_id) REFERENCES reports(id) ON DELETE CASCADE,
FOREIGN KEY (shared_by) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_report_id (report_id),
INDEX idx_recipient_email (recipient_email),
INDEX idx_expires_at (expires_at)
) ENGINE=InnoDB;
-- Insert sample data
-- Sample companies
INSERT INTO companies (name, email, phone, website, address, city, state, country, postal_code, industry, company_size, description) VALUES
('Tech Solutions Inc', 'info@techsolutions.com', '+1-555-0101', 'https://techsolutions.com', '123 Tech Street', 'San Francisco', 'CA', 'USA', '94105', 'technology', '51-200', 'Leading software development company'),
('Healthcare Partners', 'contact@healthpartners.com', '+1-555-0102', 'https://healthpartners.com', '456 Medical Ave', 'New York', 'NY', 'USA', '10001', 'healthcare', '201-500', 'Comprehensive healthcare services'),
('Green Energy Corp', 'hello@greenenergy.com', '+1-555-0103', 'https://greenenergy.com', '789 Renewable Blvd', 'Austin', 'TX', 'USA', '73301', 'energy', '11-50', 'Sustainable energy solutions');
-- Sample admin user (password: admin123)
INSERT INTO users (first_name, last_name, email, password, role, status, company_id, email_verified) VALUES
('Admin', 'User', 'admin@admin.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'admin', 'active', 1, TRUE);
-- Sample manager user (password: manager123)
INSERT INTO users (first_name, last_name, email, password, role, status, company_id, email_verified) VALUES
('John', 'Manager', 'manager@techsolutions.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'manager', 'active', 1, TRUE);
-- Sample employee user (password: employee123)
INSERT INTO users (first_name, last_name, email, password, role, status, company_id, email_verified) VALUES
('Jane', 'Smith', 'jane@techsolutions.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'employee', 'active', 1, TRUE);
-- Sample demo user (password: demo123)
INSERT INTO users (first_name, last_name, email, password, role, status, company_id, email_verified) VALUES
('Demo', 'User', 'demo@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'employee', 'active', 1, TRUE);
-- Sample reports
INSERT INTO reports (type, title, description, company_id, user_id, status, priority, format, date_from, date_to) VALUES
('financial_summary', 'Q1 2025 Financial Report', 'Quarterly financial analysis and summary', 1, 2, 'completed', 'high', 'pdf', '2025-01-01', '2025-03-31'),
('user_activity', 'User Activity Report - January', 'Monthly user engagement and activity analysis', 1, 2, 'completed', 'medium', 'excel', '2025-01-01', '2025-01-31'),
('sales_report', 'Sales Performance Q1', 'Sales team performance and metrics', 1, 3, 'processing', 'high', 'pdf', '2025-01-01', '2025-03-31');
-- Create storage directories (these would need to be created on the file system)
-- /storage/uploads/reports
-- /storage/cache
-- /logs