@echo off title Chahua Database Management Console - Windows VPS color 0B echo. echo ======================================== echo ๐Ÿ›ก๏ธ Chahua Database Console Setup echo Enterprise Database Management System echo ======================================== echo. REM Check if Node.js is installed where node >nul 2>nul if %ERRORLEVEL% NEQ 0 ( echo โŒ Node.js not found. Please install Node.js first. echo Download from: https://nodejs.org/ pause exit /b 1 ) REM Check if NPM is installed where npm >nul 2>nul if %ERRORLEVEL% NEQ 0 ( echo โŒ NPM not found. Please install NPM first. pause exit /b 1 ) REM Get Node.js version for /f "tokens=*" %%i in ('node --version 2^>nul') do set NODE_VERSION=%%i echo โœ… Node.js: %NODE_VERSION% REM Get NPM version for /f "tokens=*" %%i in ('npm --version 2^>nul') do set NPM_VERSION=%%i echo โœ… NPM: v%NPM_VERSION% REM Check PostgreSQL client tools where pg_dump >nul 2>nul if %ERRORLEVEL% EQU 0 ( echo โœ… PostgreSQL client tools available ) else ( echo โš ๏ธ PostgreSQL client tools not found in PATH echo Database backup features may not work ) REM Check if database console exists if exist "scripts\database-console" ( echo โœ… Database Console files found ) else ( echo โŒ Database Console files not found echo Please ensure you're running this from the project root pause exit /b 1 ) REM Check .env file if exist ".env" ( echo โœ… Environment configuration found ) else ( echo โš ๏ธ .env file not found if exist "config\env.example" ( echo Creating .env from example... copy "config\env.example" ".env" >nul echo โœ… Created .env from example echo Please update .env with your database credentials ) else ( echo โŒ No .env.example found. Please create .env manually ) ) echo. :MENU cls echo. echo ======================================== echo ๐ŸŽฏ Chahua Database Management Options echo ======================================== echo. echo 1. ๐ŸŒ Start Database Console (Web Interface) echo 2. ๐Ÿ” Check Database Status echo 3. ๐Ÿ”ง Fix Database Issues echo 4. ๐Ÿ“Š Database Statistics echo 5. ๐Ÿ—‚๏ธ Module Management echo 6. ๐Ÿ’พ Backup Database echo 7. ๐Ÿงช Generate Sample Data echo 8. ๐Ÿ“‹ List Tables echo 9. โš™๏ธ Advanced Options echo 0. ๐Ÿšช Exit echo. echo ======================================== echo. set /p choice="Select option (0-9): " if "%choice%"=="1" goto START_CONSOLE if "%choice%"=="2" goto CHECK_STATUS if "%choice%"=="3" goto FIX_ISSUES if "%choice%"=="4" goto SHOW_STATS if "%choice%"=="5" goto MANAGE_MODULES if "%choice%"=="6" goto BACKUP_DB if "%choice%"=="7" goto SAMPLE_DATA if "%choice%"=="8" goto LIST_TABLES if "%choice%"=="9" goto ADVANCED_OPTIONS if "%choice%"=="0" goto EXIT echo โŒ Invalid option. Please select 0-9 pause goto MENU :START_CONSOLE cls echo. echo ๐ŸŒ Starting Chahua Database Console... echo Server will be available at: http://localhost:3000 echo Console URL: http://localhost:3000/scripts/database-console echo. echo Press Ctrl+C to stop the server echo. start http://localhost:3000/scripts/database-console call npm run start goto MENU :CHECK_STATUS cls echo. echo ๐Ÿ” Checking Database Status... echo. call npm run db:status echo. pause goto MENU :FIX_ISSUES cls echo. echo ======================================== echo ๐Ÿ”ง Database Fix Options echo ======================================== echo. echo 1. Fix Forum Issues (tags column) echo 2. Fix Plugin System echo 3. Fix Payment System echo 4. Fix Core System echo 5. Fix Dashboard echo 6. Fix Bank Transfer echo 7. Fix All Issues echo 8. Return to Main Menu echo. set /p fix_choice="Select option (1-8): " if "%fix_choice%"=="1" call npm run db:fix-forum if "%fix_choice%"=="2" call npm run db:fix-plugins if "%fix_choice%"=="3" call npm run db:fix-payment if "%fix_choice%"=="4" call npm run db:fix-core if "%fix_choice%"=="5" call npm run db:fix-dashboard if "%fix_choice%"=="6" call npm run db:fix-bank if "%fix_choice%"=="7" ( echo ๐Ÿ”„ Running all database fixes... call npm run db:fix-core call npm run db:fix-payment call npm run db:fix-forum call npm run db:fix-plugins call npm run db:fix-dashboard call npm run db:fix-bank ) if "%fix_choice%"=="8" goto MENU if not "%fix_choice%"=="8" ( echo. pause ) goto MENU :SHOW_STATS cls echo. echo ๐Ÿ“Š Database Statistics... echo. call npm run db:list-tables echo. echo ๐Ÿ“ˆ Additional Stats: call npm run db:status echo. pause goto MENU :MANAGE_MODULES cls echo. echo ======================================== echo ๐Ÿ—‚๏ธ Database Module Management echo ======================================== echo. echo 1. Core Module Status echo 2. Payment Module Status echo 3. Forum Module Status echo 4. Plugin Module Status echo 5. Dashboard Module Status echo 6. Bank Transfer Module Status echo 7. All Modules Status echo 8. Return to Main Menu echo. set /p mod_choice="Select option (1-8): " if "%mod_choice%"=="1" call npm run db:fix-core if "%mod_choice%"=="2" call npm run db:fix-payment if "%mod_choice%"=="3" call npm run db:fix-forum if "%mod_choice%"=="4" call npm run db:fix-plugins if "%mod_choice%"=="5" call npm run db:fix-dashboard if "%mod_choice%"=="6" call npm run db:fix-bank if "%mod_choice%"=="7" call npm run db:status if "%mod_choice%"=="8" goto MENU if not "%mod_choice%"=="8" ( echo. pause ) goto MENU :BACKUP_DB cls echo. echo ๐Ÿ’พ Database Backup... echo. where pg_dump >nul 2>nul if %ERRORLEVEL% NEQ 0 ( echo โŒ pg_dump not found. Please install PostgreSQL client tools. echo. pause goto MENU ) call npm run db:backup echo. pause goto MENU :SAMPLE_DATA cls echo. echo ๐Ÿงช Generating Sample Data... echo. call npm run db:sample-data echo. pause goto MENU :LIST_TABLES cls echo. echo ๐Ÿ“‹ Listing Database Tables... echo. call npm run db:list-tables echo. pause goto MENU :ADVANCED_OPTIONS cls echo. echo ======================================== echo โš™๏ธ Advanced Options echo ======================================== echo. echo 1. ๐Ÿ”„ Reset Database (DANGEROUS) echo 2. ๐Ÿงน Clear Logs echo 3. ๐Ÿ” Update Security Settings echo 4. ๐Ÿ“ View Environment Config echo 5. ๐Ÿ”ง Install Dependencies echo 6. ๐Ÿ“Š Performance Test echo 7. Return to Main Menu echo. set /p adv_choice="Select option (1-7): " if "%adv_choice%"=="1" ( echo. echo โš ๏ธ This will reset ALL data. set /p confirm="Type 'RESET' to confirm: " if /i "!confirm!"=="RESET" ( call npm run db:setup ) else ( echo โŒ Reset cancelled ) echo. pause ) if "%adv_choice%"=="2" ( if exist "logs" ( del /q "logs\*.*" 2>nul echo โœ… Logs cleared ) else ( echo โš ๏ธ Logs directory not found ) echo. pause ) if "%adv_choice%"=="3" ( echo ๐Ÿ” Security settings in .env file if exist ".env" ( findstr /i "SECURITY TOKEN SECRET" ".env" ) else ( echo โŒ .env file not found ) echo. pause ) if "%adv_choice%"=="4" ( if exist ".env" ( echo ๐Ÿ“ Environment Configuration: type ".env" ) else ( echo โŒ .env file not found ) echo. pause ) if "%adv_choice%"=="5" ( echo ๐Ÿ”ง Installing dependencies... call npm install echo. pause ) if "%adv_choice%"=="6" ( echo ๐Ÿ“Š Running performance test... call npm run test echo. pause ) if "%adv_choice%"=="7" goto MENU if not "%adv_choice%"=="7" goto MENU :EXIT cls echo. echo ======================================== echo ๐Ÿ‘‹ Thank you for using echo Chahua Database Console echo ======================================== echo. echo Built with โค๏ธ by Chahua Development Thailand echo. pause exit /b 0