-- ============================================
-- Chatbot Database Setup Script
-- ============================================
-- 
-- This script creates the database and user for the chatbot application.
-- 
-- IMPORTANT: Update the database name, username, and password 
-- in this file to match your config.php settings before running.
--
-- HOW TO USE:
-- 1. Open phpMyAdmin or MySQL command line
-- 2. Update the database name, username, and password below
-- 3. Run this entire script
-- 4. Update config.php with the same credentials
-- ============================================

-- Step 1: Create the database
CREATE DATABASE IF NOT EXISTS `thesol_chat` 
CHARACTER SET utf8mb4 
COLLATE utf8mb4_unicode_ci;

-- Step 2: Create the user (comment out if using existing user)
-- Note: For XAMPP default, you can use root with empty password
-- DROP USER IF EXISTS 'thesol_user'@'localhost';
-- CREATE USER 'thesol_user'@'localhost' IDENTIFIED BY 'your_secure_password_here';

-- Step 3: Grant all privileges to the user
-- For custom user (uncomment if created above):
-- GRANT ALL PRIVILEGES ON thesol_chat.* TO 'thesol_user'@'localhost';

-- For XAMPP root user (default):
GRANT ALL PRIVILEGES ON thesol_chat.* TO 'root'@'localhost';

-- Step 4: Apply changes
FLUSH PRIVILEGES;

-- Step 5: Verify the setup
USE thesol_chat;

-- Show granted privileges (uncomment to check):
-- SHOW GRANTS FOR 'root'@'localhost';

-- ============================================
-- Example for Production/Custom Setup:
-- ============================================
-- 
-- If you're setting up for a live website like dugdhshakti.com:
--
-- CREATE DATABASE IF NOT EXISTS `dugdhshakti_chat` 
-- CHARACTER SET utf8mb4 
-- COLLATE utf8mb4_unicode_ci;
-- 
-- CREATE USER IF NOT EXISTS 'dugdhshakti_root'@'localhost' 
-- IDENTIFIED BY 'your_strong_password';
-- 
-- GRANT ALL PRIVILEGES ON dugdhshakti_chat.* 
-- TO 'dugdhshakti_root'@'localhost';
-- 
-- FLUSH PRIVILEGES;
--
-- Then update config.php:
-- define('SB_DB_NAME', 'dugdhshakti_chat');
-- define('SB_DB_USER', 'dugdhshakti_root');
-- define('SB_DB_PASSWORD', 'your_strong_password');
-- ============================================

-- Test the connection
SELECT 'Database setup completed successfully!' AS status;

-- Show current database
SELECT DATABASE() AS current_database;

-- Show tables (will be empty until installation wizard runs)
SHOW TABLES;
